Paul help!;11048975 wrote:1) so your saying that strlen, strtoupper and any other built in functions (by default) are not recognized inside a __call function?
No, this is not the case. The idea is that this is me invoking the strlen function:
$v = strlen("fubar");
but THIS is me trying to call the strlen method of some object. The result of this code is to try and find some method that the object has called strlen so we can invoke it:
$v = $myObject->strlen();
If you were to try to define your own function called strlen like this:
<?php
function strlen($v) {
echo "dang!";
}
?>
Then you will get this error:
PHP Fatal error: Cannot redeclare strlen() in /var/www/foo.php on line 5
You cannot define a function if that function already exists.
You CAN, however, define a method within a class even if that function already exists as a global function. This is perfectly fine:
class foo {
function strlen($v) {
echo "your parameter is" . $v;
}
}
The basic idea is that foo::strlen() is a different function than the global function strlen.
In your code, the class doesn't bother to define an strlen method. Instead, it defines a magic method, __call, which is how you define a function to handle attempted calls to methods that do not exist in the class or which are inaccessible (i.e., private or protected). RTFM.
Paul help!;11048975 wrote:2) ..... and you[']r[e] telling me that when strlen isn't found then $methodName (in the below code) holds the value of strlen?:
I think that sounds right. You should learn to experiment with the code so you can see for yourself. You could echo $methodName or use [man]file_put_contents[/man] to write it to a file and then look and see what's in the file.