-
echo()
You can output multiple values at once, separated by commas. echo is a language construct, not a real function, so it can't be used as part of an expression.
print()
The function print() prints a value (its arguments) and returns true if the string is displayed successfully, false otherwise.
print_r()
Strings and numbers can be simply printed, while arrays are displayed as enclosed keys and a list of values, starting with an array. But print r() doesn't make sense to output boolean and null results, because it's all printed""。Therefore, using the var dump() function is more suitable for debugging.
var_dump()
Determine the type and length of a variable, and output the value of the variable, if the variable has a value, the value of the variable is the value of the variable and return the data type. This function displays structural information about one or more expressions, including the type and value of the expression. The array will recursively value, showing its structure by indentation.
-
var dump determines the type and length of a variable, e.g. echo outputs only variables or strings print r outputs arrays a [1] => b [2] => c ).
-
Wouldn't it be clear if you write a ** yourself and test the results of these 3 functions separately???
It's a good habit to learn to code and consult with others!
But it's a good habit to experiment by yourself!
And like this simple basic question!
-
echo and print are php statements, and var dump and print r are functions.
echo outputs one or more strings, separated by commas, and no return value is a language construct rather than a true function, so it cannot be used as part of an expression.
print is also a keyword of php, there is a return value can only print out the value of simple type variables (such as int, string), if the string is displayed successfully, it will return true, otherwise it will return false
print r can print out the values of complex types of variables (such as arrays, objects) and display them in the form of a list, starting with array and object, but print r outputs boolean values and null results that make no sense, because they are all printed"", so the var dump() function is better for debugging.
var dump() determines the type and length of a variable and outputs the value of the variable.
-
echo 'outputs a string'; You can only output strings and numbers print r — print easy-to-understand information about variables, typically with an output array structure.
var dump — prints information about variables, generally used for arrays and objects to print for their own use.
-
echo outputs a string, not a function, and without a return value print r, it prints a composite type such as an array object var dump Displays structural information about one or more expressions, including the type and value of the expression. The array will recursively value, showing its structure by indentation. Distinguish.
-
The difference is obvious: the output of var export and var dump is the same, their output is the most detailed, including variable type and length, etc., but var export can directly use the result as a return value, sometimes you need to save the result and you need var export and print r is much weaker, he can neither display the variable type nor the variable length, but he has a killer feature is that the output format is very beautiful. So choose according to your personal preferences and situation, don't bother.
View the original post
-
echo is just the output of the string If the string is empty or null, you don't have anything on the screen.
print r is mainly used to print arrays and objects, similar to echo.
The var dump will show the data type and length of the printed object when it is output, even if it is an empty string or null.
-
var dump determines the type and length of a variable, e.g
a = 1;
b = 't';
echo var_dump($ta,$tb);The result is int(123) string(3)."abc"
echo only outputs variables or strings.
a = "abc";
echo $a;Output ABC
orecho "abc";Output ABC
print r output array.
a = array('a','b','c');
print_r($a);Output array ( 0 ] => a [1] => b [2] => c ).
-
There can be details of variables, such as int type, there will be corresponding prompts, print r can print variable structures, such as arrays, and echo is a simple output.
-
echo() and print() function the same as output a variable, the difference is that echo does not return a value, and print has an int return value. The function of print r is to print an easy-to-understand information about a variable, the difference with echo and print is that, for example, if an array is output, echo and print output array, while print r outputs not only array, but also the members of the array. (Extension:.)
The difference between var dump and print r is that var dump lists the details of the variable, while print r lists some basic information that is easy to understand).
-
var dump() prints the type.
print r() can only be typed with a value.
echo() is the normal output.
When you need to debug accurately, use var dump();
Generally, print r() is used for viewing
Also, echo can't show the array and the other 2 can.
-
Returns the type and value of the variable to be printed.
River. It's so different from the lake! The river water is "raw water"! The lake is "stagnant water." >>>More
Brief explanation: honey is the food of adult bees, part of the food of bee pupae and queen bees; Propolis is a medicine used by bees to ward off nest worms, etc. >>>More
Under what circumstances is it more likely that the court will award the child to the woman's custody? >>>More
Pythons are snakes There are many legends of people being entangled to death by giant pythons, but few of them are true. Pythons are large snakes that live in Latin America. The largest of these, the South American anacondas, can grow to about a meter long, although they generally do not harm humans. >>>More
The difference is in tone and usage.
Wind up is active and end up is passive Example. let's wind up and go good. >>>More