title: PHP Error reading parameter type from URL
body: <p>I want to make a simple page in PHP which read from URL a specified function with relative parameters.</p>
  
  <p>My URL is like <code>www.mysite.com/Api.php?function=sendMail&amp;name=AA000AA</code></p>
  
  <p>I get the URL using <code>$_SERVER['REQUEST_URI']</code> and pass the result to a Class i wrote which has the following construct</p>
  
  <pre><code>public function __construct($uri = '')
  </code></pre>
  
  <p>Everything works fine until I add the parameters with ampersand where I get the following error</p>
  
  <pre><code>Fatal error: Uncaught Error: Function name must be a string in /data/web/Api.php:36 Stack trace: #0 /data/web/Api.php(71): ApiAction-&gt;__construct('/app/Api.php?fu...')
  </code></pre>
  
  <p>But after a check with <code>var_dump</code> i got this</p>
  
  <pre><code>string(43) "/Api.php?function=sendMail&amp;name=AA000AA"
  </code></pre>
  
  <p>Which tells me is a string.
  I've tried to cast it but it keep giving me the same error. </p>
  
  <p>The class I'm calling has the following code</p>
  
  <pre><code>class ApiAction{
  
      protected $link;
  
      public function __construct($uri){
          $request = str_replace("/Api.php?", "", $uri);
          $parameters = explode("&amp;", $request);
          $command = array();
          foreach ($parameters as $value) {
              $tmp = explode("=", $value);
              $command[$tmp[0]] = (string)$tmp[1];
          }
          $result = '';
  </code></pre>
  
  <p>}</p>
  
  <p>But it get stuck in this error when I create a new instance of this class with</p>
  
  <pre><code>new ApiAction($_SERVER['REQUEST_URI']);
  </code></pre>
  
  <p>But, as mentioned before, it work perfectly before I add parameters with ampersand, I.E. </p>
  
  <pre><code>www.mysite.com/Api.php?function=sendMail
  </code></pre>
  
  <p>Works without any problems</p>