PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I make sure an include file exists before loading the page?


If it is essential that something you wish to include is there before you load a page, then don't use include, use require instead.

For instance if it is not just a stylesheet you are including but a file containing data that the page won't make sense without.

<?php
require("musthavethis.php");
//fatal error if not present
include("takeitorleaveit.html");
//if not present just an error message, script continues to run
?>



More website PHP Questions

How do I perform a 301 redirect with PHP?
How can I find out where a site visitor comes from?
How do I send HTTP headers with PHP?
How to find a domain name for an IP address?
How do I find a visitors IP address?