To make sure that a file is included and to stop your program if it isn't, use require and require_once. They make sure that the file is present; otherwise the PHP script's execution is halted. You should use require instead of include if the file you're including defines either critical functions that your script won't be able to execute, or variable definitions, such as databse connection details.
For example, if you attempt to rquire a file that doesn't exist, as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <head> <title>PHP</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php require('add_something.php'); echo add(2,3); ?> </p> </body> </html> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"> <head> <title>PHP</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php require('add.php'); echo add(2,3); ?> </p> </body> </html> |