Code: Select all
echo "Hello, World!\n";
Code: Select all
print "Hello, World!\n";
- echo has a void return, whereas print returns an int with a value of 1
- echo can take multiple arguments (without parentheses only), whereas print only takes one argument
- echo is slightly faster than print
C-style printf and related functions are available as well, as in the following example:
Code: Select all
printf("%s\n", "Hello, World!");
The following HTML markup contains a PHP statement that will add Hello World! to the output:
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>PHP!</title>
</head>
<body>
<p><?php echo "Hello world!"; ?></p>
</body>
</html>
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>PHP!</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>