Flames Posted October 15, 2008 Share Posted October 15, 2008 the title is pretty much the question. let me show you an example <?php $array = array(1, 2, 3); $module = $_GET['module']; if(in_array($module, $array)) { require_once("module/" . $module . ".php"); } ?> so if i put page.php?module=1 it will load module/1.php but what if i put module=2 and the page doesnt exist i get a horrible message from the webhost, so what i want to do is make it say Required module was not found. i tried using or die("message") but i just got an error. note: the code might not be 100% right i just wrote it in about 20 seconds. Link to comment https://forums.phpfreaks.com/topic/128594-php-if-require-function-fails-then-display-custom-error-message/ Share on other sites More sharing options...
prexep Posted October 15, 2008 Share Posted October 15, 2008 <?php $array = array(1, 2, 3); $module = $_GET['module']; if(in_array($module, $array)) { if(file_exists(module/$module.php)){ require_once("module/" . $module . ".php"); }else{ die("Error"); } } ?> Link to comment https://forums.phpfreaks.com/topic/128594-php-if-require-function-fails-then-display-custom-error-message/#findComment-666451 Share on other sites More sharing options...
Flames Posted October 15, 2008 Author Share Posted October 15, 2008 thanks for that Link to comment https://forums.phpfreaks.com/topic/128594-php-if-require-function-fails-then-display-custom-error-message/#findComment-666452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.