Php deep learning Note 2 (built-in functions)

Source: Internet
Author: User
Php deep learning Note 2 (built-in function) 1. call _? User _? Func _? Array calls a user-defined function. The first parameter is the function name,
The second parameter is that the function parameter must be an index array.

Function foobar ($ arg, $ arg2) {echo _ FUNCTION __, "got $ arg and $ arg2 \ n";} class foo {function bar ($ arg, $ arg2) {echo _ METHOD __, "got $ arg and $ arg2 \ n" ;}}// call call_user_func_array ("foobar", array ("one ", "two"); // class member function call $ foo = new foo; call_user_func_array (array ($ foo, "bar"), array ("three ", "four "));




2. call _? User _? Reference parameters cannot be passed in function parameters called by func.
Call_user_func (function name, parameter 1, parameter 2 ...)
call_user_func(function($arg) { print "[$arg]\n"; }, 'test');



3. create _? Function to create an anonymous function
$ Myfunc = create _? Function ('function parameters', 'function body ');
$ Myfunc (function parameter );

$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');echo "New anonymous function: $newfunc\n";echo $newfunc(2, M_E) . "\n";



4. forward _? Static _? Call _? Array calls a static function in the same way as call_user_func_array


5. forward _? Static _? Call calls a static function in the same way as call_user_func.


6. func _? Get _? Arg (index) returns an index value for a parameter in the parameter list.


7. func _? Get _? Args collects all parameters in array form
 




8. func _? Num _? Args () returns the number of parameters passed by the function.

9. function _? Exists

Check whether a function exists

Function _? Exists ("function name"); // checks whether a function exists.


10. get _? Defined _? Functions returns all defined functions in a two-dimensional array.
Including system functions (internal)
And user-defined functions (user)
Array(    [internal] => Array        (            [0] => zend_version            [1] => func_num_args            [2] => func_get_arg            [3] => func_get_args            [4] => strlen            [5] => strcmp            [6] => strncmp            ...            [750] => bcscale            [751] => bccomp        )    [user] => Array        (            [0] => myrow        ))



11. register _? Shutdown _? Function the function registered by the function. when the system executes a Fatal error that exceeds the maximum time
The registered function will still be executed.
 function add(){    code here... } register_?shutdown_?function("add");

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.