This article to share the content is the debugging function, interested friends can look at, also can give the students who need help a little reference
/***echo is a language structure that can be used without parentheses: echo or Echo () *///Print the string echo "Hello"; Echo ("Hello");//Print variable $text= "learn PHP"; echo $text; Echo ($ Text);
/**print is also a language structure that can be used without parentheses: print or print () *///prints the string "Hello";p rint ("Hello");//Print variable $text= "learn PHP";p rint $text; Print ($text);
The difference between Echo and print:
echo-capable of outputting more than one string
Print-only one string is output and always returns 1
Tip: Echo is slightly faster than print because it does not return any values
Double Quote resolution Variable
Single quotation marks do not resolve variables
$str 1= "Hello"; $str 2= "PHP"; echo "$str 1";//output: Hello Echo ' $str 2 ';//output: $STR 2
Print_r () displays easy-to-understand information about a variable. If you give a string, an integer
or float, the variable value itself is printed. If an array is given, the key will be displayed in a certain format
and elements. object is similar to an array.
Remember that Print_r () moves the pointer of the array to the last edge. Use Reset () to get the pointer back to the beginning.
Print string$str1= "Hello";p rint_r ($str 1);p rint_r ("Hello");//Print Integer$num=1024;print_r ($num);p Rint_r (1024);// Print Float$num=1024.1024;print_r ($num);p rint_r (1024.1024);//print array $cars =array ("Volvo", "BMW", "Toyota"); Print_r ($cars);/* print result Array ([0] = Volvo [1] = BMW [2] = Toyota) */
*var_dump () function
The Var_dump () method determines the type and length of a variable and outputs the value of the variable, and if the variable has a value, the output is the variable and returns the data type. for precise commissioning.
Displays structure information about one or more expressions, including the type and value of the expression. The array recursively expands the value and displays its structure by indentation.
$cars =array ("Volvo", "BMW", "Toyota"); Var_dump ($cars); /* Print result E:\wamp64\www\test.php:56:array (size=3) 0 = String ' Volvo ' (length=5) 1 = String ' BMW ' (length=3 ) 2 = String ' Toyota ' (length=6) */$n =null; Var_dump ($n);/* Print result e:\wamp64\www\test.php:59:null */
Var_export () function
The Var_export () function returns the structure information about the variable passed to the function, similar to Var_dump (), unlike the PHP code whose returned representation is legitimate. Var_export must return a valid PHP code, that is, the code returned by Var_export can be directly assigned to a variable as PHP code. And this variable gets the same value as the Var_export type.
Note three points:
1.var_export () retains the structured form of storing data.
2. But in particular, remember that the type of the variable value at this time is already a string ($var), and you can no longer take the value out of the array to
3. Var_export output NULL for resource-type variables
$cars =array ("Volvo", "BMW", "Toyota"); Var_export ($cars); /* Print result Array (0 = ' Volvo ', 1 = ' BMW ', 2 = ' Toyota ',) */
debug_zval_dump () function
Debug_zval_dump () output is similar to Var_dump, the only added value is RefCount, which is the number of times a variable is referenced, which is an important feature of PHP's copy on write (copy-on-write) mechanism.
$cars =array ("Volvo", "BMW", "Toyota"); Debug_zval_dump ($cars); /* Print result Array (3) RefCount (2) {[0]=> string (5) "Volvo" RefCount (1) [1]=> string (3) "BMW" RefCount (1) [2]=> str ING (6) "Toyota" RefCount (1)} */
/***echo is a language structure that can be used without parentheses: echo or Echo () *///Print the string echo "Hello"; Echo ("Hello");//Print variable $text= "learn PHP"; echo $text; Echo ($ Text);
/**print is also a language structure that can be used without parentheses: print or print () *///prints the string "Hello";p rint ("Hello");//Print variable $text= "learn PHP";p rint $text; Print ($text);
The difference between Echo and print:
echo-capable of outputting more than one string
Print-only one string is output and always returns 1
Tip: Echo is slightly faster than print because it does not return any values
Double Quote resolution Variable
Single quotation marks do not resolve variables
$str 1= "Hello"; $str 2= "PHP"; echo "$str 1";//output: Hello Echo ' $str 2 ';//output: $STR 2
Print_r () displays easy-to-understand information about a variable. If you give a string, an integer
or float, the variable value itself is printed. If an array is given, the key will be displayed in a certain format
and elements. object is similar to an array.
Remember that Print_r () moves the pointer of the array to the last edge. Use Reset () to get the pointer back to the beginning.
Print string$str1= "Hello";p rint_r ($str 1);p rint_r ("Hello");//Print Integer$num=1024;print_r ($num);p Rint_r (1024);// Print Float$num=1024.1024;print_r ($num);p rint_r (1024.1024);//print array $cars =array ("Volvo", "BMW", "Toyota"); Print_r ($cars);/* print result Array ([0] = Volvo [1] = BMW [2] = Toyota) */
*var_dump () function
The Var_dump () method determines the type and length of a variable and outputs the value of the variable, and if the variable has a value, the output is the variable and returns the data type. for precise commissioning.
Displays structure information about one or more expressions, including the type and value of the expression. The array recursively expands the value and displays its structure by indentation.
$cars =array ("Volvo", "BMW", "Toyota"); Var_dump ($cars); /* Print result E:\wamp64\www\test.php:56:array (size=3) 0 = String ' Volvo ' (length=5) 1 = String ' BMW ' (length=3 ) 2 = String ' Toyota ' (length=6) */$n =null; Var_dump ($n);/* Print result e:\wamp64\www\test.php:59:null */
Var_export () function
The Var_export () function returns the structure information about the variable passed to the function, similar to Var_dump (), unlike the PHP code whose returned representation is legitimate. Var_export must return a valid PHP code, that is, the code returned by Var_export can be directly assigned to a variable as PHP code. And this variable gets the same value as the Var_export type.
Note three points:
1.var_export () retains the structured form of storing data.
2. But in particular, remember that the type of the variable value at this time is already a string ($var), and you can no longer take the value out of the array to
3. Var_export output NULL for resource-type variables
$cars =array ("Volvo", "BMW", "Toyota"); Var_export ($cars); /* Print result Array (0 = ' Volvo ', 1 = ' BMW ', 2 = ' Toyota ',) */
debug_zval_dump () function
Debug_zval_dump () output is similar to Var_dump, the only added value is RefCount, which is the number of times a variable is referenced, which is an important feature of PHP's copy on write (copy-on-write) mechanism.
$cars =array ("Volvo", "BMW", "Toyota"); Debug_zval_dump ($cars); /* Print result Array (3) RefCount (2) {[0]=> string (5) "Volvo" RefCount (1) [1]=> string (3) "BMW" RefCount (1) [2]=> str ING (6) "Toyota" RefCount (1)} */