Which of the following heroes can tell me what is the return value of _ call () in php !~~ Classmy {public $ name & quot; My Class & quot; function _ tostring () {return $ this-& gt; name. & quot; is an empty class & quot ;. & quot; & lt; br & gt; & quot;} which of the following functions can tell me the return value of _ call () in php! ~~
Class my {
Public $ name = "My classes ";
Function _ tostring (){
Return $ this-> name. "is an empty class "."
";
}
Function _ call ($ n, $ v ){
Echo "nonexistent method:". $ n ."
";
Echo "error value:", print_r ($ v )."
"; // Output 1 at the end.
}
}
$ P = new my ();
Echo $ p;
$ P-> no ("first", 6, );
The following is the running result: my class is an empty class.
Method that does not exist: no
Error value: Array ([0] => first [1] => 6 [2] => a) 1
Why is there a 1 at the end ??? Puzzling !~~
------ Solution --------------------
Bool print_r (mixed expression [, bool return])
Return value of print_r
Function _ call ($ n, $ v ){
Echo "nonexistent method:". $ n ."
";
Print_r ($ v );
}
------ Solution --------------------
Return parameter. If this parameter is set to TRUE, print_r () does not print the result (this is the default action), but returns its output.
So we can do the same.
Echo "error value:". print_r ($ v, true )."
"; // Output 1 at the end.
------ Solution --------------------
This is not a problem with the _ call method. 1 is the return value of print_r.
Function _ call ($ n, $ v)
{
Echo "nonexistent method:". $ n ."
";
Echo "error value:"; print_r ($ v); // output 1 at the end.
}
So that 1 is not output.
Echo: ". print_r ($ v, true )."
"; In this way, the return value is output.
Http://zhidao.baidu.com/question/256918769.html
Http://cn2.php.net/print_r/