/*******echo********/
echo-output one or more strings
description
Echo (String arg1 [, String ...])
Echo () is not actually a function (it is a language structure), so you do not need to use parentheses. Echo () (unlike some other language constructs) is not like a feature, so it cannot always be used in functions. In addition, if you want to pass echo () of multiple parameters, the argument must not be enclosed in parentheses.
Echo () is a command and cannot return a value. Echo can be followed by a number of parameters, separated by semicolons, such as:
echo $myvar 1;
Echo, $myvar, "bold";
/*******print********/
print-output one or more strings
description
int print (string arg)
Print () is actually not a real function (it is a language structure), so you do not need to use its parentheses in the argument list.
Can return a value that can have only one parameter
/*******print_r () ********/
Print_r
(PHP 4, PHP 5)
print_r– prints easy-to-understand information about variables.
Describe
BOOL Print_r (mixed expression [, bool return])
Note: The parameter return is added when PHP 4.3.0
Print_r () displays easy-to-understand information about a variable. If a string, integer, or float is given, the variable value itself is printed. If an array is given, the keys and elements are displayed in a certain format. 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.
$a = Array (' a ' = = ' Apple ', ' B ' + = ' banana ', ' c ' = = Array (' x ', ' y ', ' z '));
Print_r ($a);
?>
The above code will output:
Array
(
[A] = Apple
[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 () The result will not be printed (this is the default action), but its output is returned.
Example 1. Return parameter Example
$b = Array (' m ' = = ' monkey ', ' foo ' = ' bar ', ' x ' = = Array (' x ', ' y ', ' z '));
$results = Print_r ($b, true); $results contains the output of the Print_r
?>
Note:If you want to capture the output of Print_r () in a version prior to PHP 4.3.0, you can use the output control function.
Note:In versions prior to PHP 4.0.4, if the given array or object contained a reference directly or indirectly to itself, Print_r () would continue forever. Print_r ($GLOBALS) is an example, because $GLOBALS itself is a global variable that contains a reference to itself.
/*******sprintf () ********/
/*******var_dump () ********/
Var_dump
(PHP 3 >= 3.0.5, PHP 4, PHP 5)
var_dump-information about the print variable
description
void Var_dump (mixed expression [, mixed expression [, ...]])
This function 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.
Tip: To prevent the program from outputting the results directly to the browser, you can use the output control functions to capture the output of this function and save them to a variable such as a string type.
/*******var_export () ********/
var_export
(PHP 4 >= 4.2.0, PHP 5)
var_export- The string that outputs or returns a variable represents the
description
mixed var_export (mixed expression [, bool return])
This function returns the structure information about the variable passed to the function, similar to Var_dump (), unlike the PHP code whose returned representation is valid. The
Var_export must return a valid PHP code, which means that the code returned by Var_export can be directly assigned a variable as a PHP code. And this variable gets the value of the same type as the Var_export
However, when the variable type is resource, it cannot be copied simply, so when the Var_export variable is the resource type, Var_ Export returns null
copy code code as follows:
$res = fopen (' status.html ', ' R ');
Var_dump ($res);//resource (2) of type (stream)
Var_export ($res);//null
You can set the second argument of a function to TRUE, This returns the representation of the variable.
copy code code is as follows:
$a = Array (1, 2, Array ("A", "B", "C"));
Var_export ($a);
/* 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
*/
?>
http://www.bkjia.com/PHPjc/327679.html www.bkjia.com true http://www.bkjia.com/PHPjc/327679.html techarticle /*******echo********/echo-Output one or more strings describing echo (string arg1 [, String ...]) echo () is not actually a function (it is a language structure), so you ...