/*******Echo********/
Echo-Output one or more strings
Description
Echo (string arg1 [, string...]) echo () is actually not a function (it is a language structure), so you do not need to use parentheses. Echo () (unlike some other languages) is not like a function, so it cannot always be used in functions. In addition, if you want to pass the echo () of multiple parameters, the parameters must not be enclosed in brackets.
Echo () is a command and cannot return values. ECHO can be followed by multiple parameters separated by semicolons, for example:
Echo $ myvar1;
Echo 1, 2, $ myvar, "bold ";
/*******Print********/
Print-OutputOne or more strings
Description
Int print (string Arg) print () is actually no real function (it is a language structure), so you do not need to use the brackets in its parameter list.
Only one parameter can be returned.
/*******Print_r ()********/
Print_r
(PHP 4, PHP 5)
Print_r-prints easy-to-understand information about variables.
Description
Bool print_r (mixed expression [, bool return])
Note: The Return parameter is added in PHP 4.3.0.
Print_r () displays easy-to-understand information about a variable. If the value is string, integer, or float, the variable value is printed. If array is provided, keys and elements are displayed in a certain format. Objects are similar to arrays.
Remember, print_r () will move the array pointer to the last edge. Use reset () to bring the pointer back to the beginning.
$ A = array ('A' => 'apple', 'B' => 'bana', 'c' => array ('x ', 'y', 'z');
print_r ($ A);
?>
the above Code will output:
array
(
[a] => appl E
[B] => banana
[c] => array
(
[0] => x
[1] => Y
[2] => Z
)
)
if you want to capture the output of print_r (), you can use the return parameter. If this parameter is set to true, print_r () does not print the result (this is the default action), but returns its output.
Example 1. Return parameter example
<? PHP
$ B = array ('M' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y ', 'Z '));
$ Results = print_r ($ B, true); // $ Results contains the output result of print_r
?>
Note: If you want to capture the output of print_r () in a version earlier than PhP 4.3.0, you can use the output control function.
Note: In versions earlier than PhP 4.0.4, if the given array or object contains a reference pointing directly or indirectly to itself, print_r () will continue forever. Print_r ($ globals) is an example, because $ globals itself is a global variable and contains references pointing to itself.
/*******Sprintf()********/
/******* Var_dump () ********/
Var_dump
(PHP 3> = 3.0.5, PHP 4, PHP 5)
Var_dump-prints information about a variable.
Description
Void var_dump (mixed expression [, mixed expression [,...])
This function displays the structure information about one or more expressions, including the expression type and value. The array recursively expands the value and displays its structure through indentation.
Tip: to preventProgramDirectly output the results to the browser. You can use the output control function to capture the output of the function and save them to a variable of the string type, for example.
/******* Var_export ()********/
Var_export
(PHP 4> = 4.2.0, PHP 5)
Var_export-String Representation of the output or returned variable
Description
Mixed var_export (mixed expression [, bool return])
This function returns the structure information about the variables passed to this function. It is similar to var_dump (). The difference is that the returned representation is legal PHP code.
Var_export must return valid PHP code, that is, the Code returned by var_export can be directly assigned a variable as a PHP code. And this variable will get the same type value as var_export.
However, when the variable type is resource, it cannot be simply copied. Therefore, when the var_export variable is resource type, var_export returns NULL.
$ Res =
Fopen ('Status.html ', 'R ');
Var_dump (
$ Res );
// Resource (2) of type (Stream)
Var_export (
$ Res );
// Null
You can set the second parameter of the function to true to return the expression of the variable.
<PRE>
<? PHP
$ A = array (1, 2, array ("A", "B", "C "));
Var_export ($ );
/* Output:
Array (
0 => 1,
1 => 2,
2 =>
Array (
0 => 'A ',
1 => 'B ',
2 => 'C ',
),
)
*/
$ B = 3.1;
$ V = var_export ($ B, true );
Echo $ V;
/* Output:
3.1
*/
?>
</PRE>