Shiny_Charizard Posted December 26, 2008 Share Posted December 26, 2008 I wanted to know if there was anyway to find out if it required a file correctly? Example 1: <?php $req = require_once 'file.php'; if ($req == false) { echo "File not found!"; } ?> Example 2: <?php require_once 'file.php' or exit ("File not found!"); ?> Thanks you. Link to comment https://forums.phpfreaks.com/topic/138429-solved-require_once-question/ Share on other sites More sharing options...
ohdang888 Posted December 26, 2008 Share Posted December 26, 2008 if the file is not found, the script with die and give an error. Theres no need for all that checking you did, php automatically does it... test it out... try to require a file that doesn't exist Link to comment https://forums.phpfreaks.com/topic/138429-solved-require_once-question/#findComment-723784 Share on other sites More sharing options...
Shiny_Charizard Posted December 26, 2008 Author Share Posted December 26, 2008 I know but I want to make it show my own message. Link to comment https://forums.phpfreaks.com/topic/138429-solved-require_once-question/#findComment-723789 Share on other sites More sharing options...
ohdang888 Posted December 26, 2008 Share Posted December 26, 2008 uh? whats the point in that? Link to comment https://forums.phpfreaks.com/topic/138429-solved-require_once-question/#findComment-723828 Share on other sites More sharing options...
Sagi Posted December 26, 2008 Share Posted December 26, 2008 Use file_exists to check if the file exists, then include the file only if it does. if (file_exists("file.php")) { require_once "file.php"; } else { echo "File not found"; } Link to comment https://forums.phpfreaks.com/topic/138429-solved-require_once-question/#findComment-723890 Share on other sites More sharing options...
Shiny_Charizard Posted December 26, 2008 Author Share Posted December 26, 2008 Thanks, that worked perfectly! Link to comment https://forums.phpfreaks.com/topic/138429-solved-require_once-question/#findComment-723962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.