title: Asterisk Server Pass Variable from Dialplan to AGI Script
body: <p>My Dialplan is like this</p>
  
  <pre><code>[dial-plan]
  exten =&gt; s,1,Answer()
  exten =&gt; s,n,Noop(exten = ${EXTEN}
  exten =&gt; s,n,Macro(dumpvars)
  exten =&gt; s,n,Macro(record-enable)
  exten =&gt; s,n,AGI(success.php)
  exten =&gt; i,1,Noop(REASON = ${REASON})
  exten =&gt; i,n,Macro(dumpvars)
  exten =&gt; i,n,AGI(faile.php)
  exten =&gt; failed,1,Noop(REASON = ${REASON})
  exten =&gt; failed,n,Macro(dumpvars)
  exten =&gt; failed,n,AGI(faile.php)
  </code></pre>
  
  <p>I want to catch from where faile.php called , It may be called from <code>failed</code> or from <code>i</code> . How can I check this</p>
  
  <p>I need to make like this is faile.php</p>
  
  <pre><code>if($some_var == 1){
       //Invalid
  }
  elsif($some_var == 2){
      //Failed
  }
  </code></pre>