Home > Backend Development > PHP Tutorial > Things to note about the call_user_func function_PHP tutorial

Things to note about the call_user_func function_PHP tutorial

WBOY
Release: 2016-07-20 11:02:33
Original
1164 people have browsed it

Notes on call_user_func function

parse error: syntax error, unexpected t_list, expecting t_string in

I kept getting the above problem when using this function today. Referring to the official manual, there is no introduction to the precautions for using it.

Attachment:
mixed call_user_func ( callback $function [, mixed $parameter [, mixed $... ]] )
Any built-in or user-defined function can be passed, except language constructs such as array(), echo(), empty(), eval(), exit(), isset(), list(), print() and unset( ).

My problem is that there is a method name called list in the object. Therefore, it conflicts with the language structure list() of the PHP tutorial.

See example application

The call_user_func function is similar to a special method of calling a function. The method of use is as follows:
function a($b,$c)
{
echo $b;
echo $c;
}
call_user_func('a', "111","222");
call_user_func('a', "333","444");
//Display 111 222 333 444
?>

It is strange to call the method inside the class. It actually uses array. I don’t know what the developer thought about it. Of course, new is omitted, which is also full of novelty:
class a {
function b($c)
{
echo $c;
}
}
call_user_func(array("a", "b"),"111");
//Display 111
?>

The call_user_func_array function is very similar to call_user_func, except that the parameters are passed in a different way to make the parameter structure clearer:
function a($b, $c)
{
echo $b;
echo $c;

}
call_user_func_array('a', array("111", "222"));
//Display 111 222
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445355.htmlTechArticleNotes on the call_user_func function parse error: syntax error, unexpected t_list, expecting t_string in When using this function today The above question keeps popping up. See the official...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template