Common output statements
Echo ()
Multiple values can be output at one time, and multiple values are separated by commas. Echo is a language structure (language construct), not a real function and therefore cannot be used as part of an expression.
Print ()
The function print () prints a value (its arguments) and returns True if the string is successfully displayed, otherwise false.
Print_r ()
You can simply print the string and the number, and the array is displayed with the enclosed key and the list of merits, starting with an array. However, the result of Print_r () output Boolean and null is meaningless because it is all printed "\ n". 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 for the variable and the return data type. 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.
Look at the code below form1.php
<Html><Head><Title></Title></Head><Body><FormAction= "formprocess1.php"Method= "POST"><Table><Tr><Td>name</Td><Td><InputType= "Text"Name= "Name"Id= "Name"/></Td></Tr><Tr><Tdcolspan= "2"Style= "Text-aligh:center"><InputType= "Submit" Name= "Submit" value< Span style= "color: #0000ff;" >= "Submit" /> </> </tr> </table> Span style= "color: #0000ff;" ></form> </< Span style= "color: #800000;" >body></html< Span style= "color: #0000ff;" >>
formprocess1.php
<Html><Head><Title></Title><Body><?PHP echo ' ?><pre> <strong>degug:</ strong> <?php Echo ($_post); ?> </pre> </body> Span style= "color: #0000ff;" ></head></< Span style= "color: #800000;" >html>
The result of using the echo output is:
Hello!
Degug: Array
The result of using the print () output is:
Hello!
Degug: Array
The result of using the Print_r () output is:
Hello!
Degug: Array ( [name] + [Submit] = submit)
The result of using the Var_dump () output is:
Hello!
degug:Array (2) { ["name"]=> string (0) "" ["Submit"]=> string (6) "Submit"}
We can see that the var_dump () output is the most informative, so use this function frequently to debug the program.
Echo (), print (), Print_r (), Var_dump difference?