O'Reilly logo

Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP by Brent Ware, James Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.6. Built-In PHP Functions

PHP has a number of built-in functions. We sample a few, but there is no way we can cover all of them in this overview. See the documents (www.php.net/manual/en/funcref.php) or a suggested book for a complete list.

12.6.1. Important Functions

Let’s start with two important functions: print() and die().

print()

This function outputs a string that ends up being displayed in the browser. For example:

print "<h1>PHP Results</h1>"; 
print "$name : $age : $result[0]"; 
print "<hr>"; 

The print() function is essentially the same as the echo statement. These two do the same thing—they both produce the text “hello, world!”:

echo "hello, world!"; 
print "hello, world!"; 
die()

PHP also has the die() function, which outputs ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required