Parsing the role of call_user_func_array in php _ PHP Tutorial

Source: Internet
Author: User
Parse call_user_func_array in php. 1. directly call the method to copy the code: functiontest ($ a, $ B) {echo Test 1 :. $. $ B;} calls the test method. array (asp, php) corresponds to the corresponding parameter call_user_func _ 1. directly call the method

The code is as follows:


Function test ($ a, $ B)
{
Echo 'test 1: '. $ a. $ B;
}
// Call the test method. array ("asp", 'php') corresponds to the corresponding parameter.
Call_user_func_array ('test', array ("asp", 'php '));

2. call methods in the class through the class

The code is as follows:


Class test2 {
Function phpSay ($ a, $ B)
{
Echo 'test 2: '. $ a. $ B;
}
}
$ O = new test2 ();
// Equivalent to: $ o-> phpSay ('php', '');
Call_user_func_array (array (& $ o, 'phpser'), array ('php', ''));

The response code is as follows: function test ($ a, $ B) {echo 'test 1 :'. $. $ B;} // call the test method. array ("asp", 'php') corresponds to the corresponding parameter call_user_func _...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.