Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
__toString && __call
<?php
class example {
const val = "print value";
public function __toString(){
return self::val;
}
public function __call($name,$arr){
echo "There is no method called {$name}";
}
}
$exam = new example();
echo $exam; // "print value"
$exam->s(); //"There is no method called {$name}";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment