Rich Darvins Rich Darvins - 5 months ago 15
PHP Question

How to tell if a file has already been required?

I've created a php global file (globs.php), and have required it in all of my pages.
However, some pages are now including other pages, and I'm getting an error when it tries to require globs.php again.

How can I tell if a file has been required? That way, I could do if !required('globs.php') require('globs.php').


You can also make your own require_file function:

function require_file($file_path){
    static $required_files=array();
        require $file_path;
        return true;
    return false;