Cody Butz
Cody Butz

Reputation: 294

php include failing?

I have this code:

if (file_exists(CHAL_DIR . $row['filename'])) { // Check if the file exists or not.
                         if(!include('' . CHAL_DIR . $row['filename'])) { // Include the Challenge's class file.
                            echo "Include failed.";
                         } else {
                            echo "I win.";
                         }


                    } else {
                         echo "File " . CHAL_DIR . $row['filename'] . " does not exist.";
                    }

But it is not printing any errors? It seems like it just kills the php code after that include? It doesnt even print Include failed.

Upvotes: 0

Views: 1865

Answers (2)

Matteo Riva
Matteo Riva

Reputation: 25060

It depends on the content of the included file: if it has an exit call or any other sort of termination, then PHP will stop there.

Upvotes: 3

Prisoner
Prisoner

Reputation: 27618

Have you turned on PHP errors, either for your whole install (via php.ini) or via using:

error_reporting(E_ALL);
ini_set('display_errors', '1');

at the top of your script.

Upvotes: 2

Related Questions