PHP 5 echo and print statements

PHP 5 echo and print statements

There are two basic output methods in PHP: echo and print.

In this chapter we will discuss the usage of the two statements in detail and demonstrate how to use echo and print in examples.

#Qp Echo and Print sentences

Echo and Print String

· who’s who’ who’s who who’s who who who who who who who’s input’s, print - only allowed to output a string, and the return value is always 1

Tips: echo outputs faster than print, echo has no return value, and print has a return value of 1.

P

HP echo statementecho is a language structure and can be used without parentheses or Add parentheses: echo or echo().

Display string

The following example demonstrates how to use the echo command to output a string (the string can contain HTML tags):

Example

PHP is fun!"; echo "Hello world!
"; echo "I'm about to learn PHP!
"; echo "This", " string", " was", " made", " with multiple parameters."; ?>

Display variables

The following example demonstrates how to use the echo command to output variables and strings:

Example

"; echo "Study PHP at $txt2"; echo "My car is a {$cars[0]}"; ?>

PHP print statement

print is also a language structure that can use parentheses or not: print or print().

Display string

The following example demonstrates how to use the print command to output a string (the string can contain HTML tags):

Example

PHP is fun!"; print "Hello world!
"; print "I'm about to learn PHP!"; ?>

Display variables

The following example demonstrates how to use the print command to output variables and strings:

Example

"; print "Study PHP at $txt2"; print "My car is a {$cars[0]}"; ?>

Continuing Learning
||
"; print "Study PHP at $txt2"; print "My car is a {$cars[0]}"; ?>
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!