<p>PHP5 has a "magic method" <code>__call()</code>that can be defined on any class that is invoked when an undefined method is called -- it is roughly equivalent to Ruby's <code>method_missing</code> or Perl's <code>AUTOLOAD</code>. Is it possible to do something like this in older versions of PHP?</p>

[{'answer_id': 76399, 'author': 'Adam Wright', 'author_id': 1200, 'author_profile': 'https://Stackoverflow.com/users/1200', 'pm_score': 0, 'selected': False, 'text': '<p>I recall using it, and a little bit of googling suggests that</p>\n\n<pre><code>function __call($method_name, $parameters, &amp;$return)\n{\n  $return_value = "You called ${method_name}!";\n}\n</code></pre>\n\n<p>as a member function will do the job.</p>\n'}, {'answer_id': 112606, 'author': 'jes5199', 'author_id': 13195, 'author_profile': 'https://Stackoverflow.com/users/13195', 'pm_score': 2, 'selected': False, 'text': '<p>The most important bit that I was missing was that <code>__call</code> exists in PHP4, but you must enable it on a per-class basis by calling <code>overload()</code>, as seen in <a href="http://us2.php.net/manual/en/function.overload.php" rel="nofollow noreferrer">php docs here</a> .\nUnfortunately, the __call() function signatures are different between PHP4 and PHP5, and there does not seem to be a way to make an implementation that will run in both.</p>\n'}]
['https://Stackoverflow.com/questions/76328', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13195/']