title: How to call a method of anonymous object php?
body: <p>I need to create anonymous object and call it's method</p>
  <pre class="lang-php prettyprint-override"><code>$obj = new stdClass();
  $obj-&gt;Greeting = function (string $d){return &quot;Hello &quot;.$d;};
  $greetings = $obj-&gt;Greeting(&quot;world!&quot;); 
  </code></pre>
  <p>But when I try to execute this code I get an error</p>
  <p><code>Call to undefined method stdClass::Greeting()</code></p>
  <p>What's wrong?</p>