Skip to content

Instantly share code, notes, and snippets.

@mpmont
Created October 6, 2012 21:21
Show Gist options
  • Save mpmont/3846171 to your computer and use it in GitHub Desktop.
Save mpmont/3846171 to your computer and use it in GitHub Desktop.
magic methods php
<?php
class MethodTest
{
public function __call($name, $arguments)
{
// Note: value of $name is case sensitive.
echo "Calling object method '$name' "
. implode(', ', $arguments). "\n";
}
public static function __callStatic($name, $arguments)
{
// Note: value of $name is case sensitive.
echo "Calling static method '$name' "
. implode(', ', $arguments). "\n";
}
}
$obj = new MethodTest;
$obj->runTest('in object context');
MethodTest::runTest('in static context');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment