Class 1/Object
_ Autoload (string $ name) is used to automatically load classes.
Bool class_alias ($ old, $ new) alias the class name
Bool class_exists ($ name, $ autoload = false) check whether the class is defined
Array get_class_methods ($ name) returns a list of all methods of the class.
Array get_class_vars ($ name) returns the list of all attributes of the class.
Array get_object_vars () returns an associated array composed of object attributes.
String get_class ($ OBJ) returns the Class Name of the object
String get_parent_class ($ OBJ) returns the parent class name of the object or class.
Get_declared_classes get_declared_interfaces get_decleared_traits returns the classes, interfaces, and features defined in the script.
Bool is_a ($ OBJ, $ class) checks whether the object is an instance of the class
Bool is_subclass_of ($ OBJ, $ name) check whether the object is a subclass of the class
Method_exists ($ name, $ cname) check whether the class defines the Method
Property_exists ($ name, $ cname) check whether the class defines attributes
2 Variable Processing
Debug_zval_dump () dump a variable information, including reference count
Doubleval () intval () strval to float/Integer/random
Get_resource_type () returns the resource type
Settype/GetType (): Set and obtain the variable type
Is_array is_bool is_callable is_double is_float is_int is_long is_null is_numberic is_object is_resource is_string
Var_dump/var_export/print_r print variable. The output formats of the three variables are slightly different.
3. function processing
Mixed call_user_func_array (callable $ func, array $ Params) calls back func and transmits Parameters
Array func_get_args (void) returns all parameters of the function.
Int func_num_args (void) returns the number of parameters of the function.
Mixed func_get_arg (INT $ num) returns the num parameter of the function.
Bool function_exists ($ name) check whether the function has been defined
Register_shutdown_function ($ callback [, $ Param...]) executes the function when the script is registered.
<?phpfunction foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2\n";}class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2\n"; }}// Call the foobar() function with 2 argumentscall_user_func_array("foobar", array("one", "two"));// Call the $foo->bar() method with 2 arguments$foo = new foo;call_user_func_array(array($foo, "bar"), array("three", "four"));?>
4 reflection
Reflection provides reverse engineering capabilities for PHP classes and objects. It can obtain various information about classes, objects, functions, member methods, and member attributes. First, let's look at the class hierarchy of the reflection child.
As the base class, the reflection child provides the export static method. Export ($reflector
. The reflectionclass class is used to obtain the PHP class information, and the reflectionobject is used to obtain the PHP Object Information. Refectionmethod is used to obtain information about member methods, while reflectionfunction is used to obtain information about functions. Reflectionproperty is used to obtain information about the member attributes of a class. Reflectionparameter is used to obtain information about parameters of methods and functions. Reflectionextension is used to obtain PHP extensions. The constructor of these functions can directly generate various reflection subtors, and can also be exported between reflection subtors through the member functions. For example, the method object can be obtained through the getmethod method of the class, while parmeter can be obtained through the getparameter method of the function and method. Radial functions can also obtain their declared class names.
The role of the member methods of a specific class is not described here. The role of the member methods should be better understood by name. Reflection has many functions. reflection can be used to reverse engineer PHP classes or extensions without documents, and obtain related information and comments. Another use is to provide a search class through reflection to obtain all the plug-ins of a specific instance interface.
Here is an example of using PHP reflection to load the plug-in framework. Http://dengbaoleng.iteye.com/blog/1504589
5. Filter
First, we will introduce the filter types validate and sanitize. The former is used for verification, and the latter is used for correction.
Filter_validate_boolean check bool type
Filter_validate_email filter_sanitize_email
Filter_validate_float filter_sanitize_number_float
Filter_validate_int filter_sanitize_number_int
Filter_validate_ip
Filter_validate_url filter_sanitize_url
Filter_validate_regexp
Mixed filter_var (mixed $ var, int $ filter_type, mixed $ OPT) filters from $ VaR Based on the specified type and options and returns the filtered results.
Filter_input ($ type, $ var, int $ filter, $ OPT)
Bool filter_has_var ($ type, $ var) check whether a specific type of variable exists
<?php$a = 'joe@example.org';$b = 'bogus - at - example dot org';$c = '(bogus@example.org)';$sanitized_a = filter_var($a, FILTER_SANITIZE_EMAIL);if (filter_var($sanitized_a, FILTER_VALIDATE_EMAIL)) { echo "This (a) sanitized email address is considered valid.\n";}$sanitized_b = filter_var($b, FILTER_SANITIZE_EMAIL);if (filter_var($sanitized_b, FILTER_VALIDATE_EMAIL)) { echo "This sanitized email address is considered valid.";} else { echo "This (b) sanitized email address is considered invalid.\n";}$sanitized_c = filter_var($c, FILTER_SANITIZE_EMAIL);if (filter_var($sanitized_c, FILTER_VALIDATE_EMAIL)) { echo "This (c) sanitized email address is considered valid.\n"; echo "Before: $c\n"; echo "After: $sanitized_c\n"; }?>
6 classkit
This extension defines functions that allow dynamic PHP class operations at runtime.
Classkit_import ($ filename)
Classkit_method_add ()
Classkit_method_copy ()
Classkit_method_redefine ()
Classkit_method_remove ()
Classkit_method_rename ()