nomaam Posted August 29, 2007 Share Posted August 29, 2007 Hello: I am new to PHP and am trying to learn what I can. I am stuck on a problem where I am working with a try block to catch if a required file is not found here is the code so far: try { if (!@eval(require("header.inc.php"))) { throw new exception('File not found'); }else{ print "File found.\n"; } } catch (Exception $e) { echo 'Caught exception: '.$e->getMessage()."\n"; } The problem seem to be the syntax for the eval() function. I have tried many many different variations on the syntax including changing all the quotes to different types and removing them and even placing the string in a variable then trying to evaluate it. Nothing seems to work. Any help would be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/67190-eval-problem/ Share on other sites More sharing options...
Ken2k7 Posted August 29, 2007 Share Posted August 29, 2007 Well if you want to see if the file: header.inc.php exists, you can use file_exists(). Link to comment https://forums.phpfreaks.com/topic/67190-eval-problem/#findComment-337073 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.