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 ...

Get Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.