Passing variable from Asterisk Script to AGI

Anybody can help me out and let me know what am I doing wrong? I am trying to pass varaible from Asterisk 11 script to AGI, here is:

Asterisk 11 Script:
exten => _.,1,AGI(testj.php,xyz)
exten => _.,n,NoOP(${Num})
exten => _.,hangup()

AGI (php) script:

#!/usr/bin/php -q

<?php require 'phpagi.php'; $agi = new AGI(); $agi->set_variable("Num", "$argv[1]"); ?>

I tried $argv[0] also, not sure if array start with 1 or 0. But none showed up, I would think I should see “xyz” no?

Whitout seeing your phgagi.php it is just wild guessing…
If i recall well AGI reads/writes from stdin/stdout

http://www.voip-info.org/wiki/view/Asterisk+AGI+php

Hi try this dial plan it should work…

exten => _.,1,AGI(testj.php,${xyz})
exten => _.,n,NoOP(${Num})
exten => _.,hangup()

AGI (php) script:

#!/usr/bin/php -q

<?php require 'phpagi.php'; $agi = new AGI(); ${temp}= $argv[1] $agi->set_variable("temp",${Num}); ?>