title: PHP -  MySQL gets value of out parameter from a stored procedure
body: <p>I have called a MySQL stored procedure from PHP using <code>mysqli</code>. This has one out parameter.</p>
  
  <pre><code>$rs = $mysqli-&gt;query("CALL addNewUser($name,$age,@id)");
  </code></pre>
  
  <p>Here, @id is the out parameter. Next, I fire the following query to get the value of the out parameter:</p>
  
  <pre><code>$rs2 = $mysqli-&gt;query("SELECT @id");
  while($row = $rs-&gt;fetch_object()){
      echo var_dump($row);
  }
  </code></pre>
  
  <p>The output of <code>var_dump</code> is as follows.</p>
  
  <pre><code>object(stdClass)#5 (1) { ["@id"]=&gt; string(6) "100026" }
  </code></pre>
  
  <p>So, now I want to retrieve the value of <code>@id</code>, which I am unable to. I tried <code>$row[0]-&gt;{@id}</code> but this gave following error:</p>
  
  <blockquote>
    <p>PHP Fatal error:  Cannot use object of type stdClass as array</p>
  </blockquote>