darksniperx Posted November 25, 2007 Share Posted November 25, 2007 I would like to know how to validate included or required pages for their existence. something like this-> if(include_once['mypage']== nulll) { //do nothing } else { include_once['mypage']; } Quote Link to comment https://forums.phpfreaks.com/topic/78739-solved-validate-include-include_once-require-etc/ Share on other sites More sharing options...
hitman6003 Posted November 25, 2007 Share Posted November 25, 2007 use the file_exists function http://www.php.net/file_exists Quote Link to comment https://forums.phpfreaks.com/topic/78739-solved-validate-include-include_once-require-etc/#findComment-398489 Share on other sites More sharing options...
darksniperx Posted November 25, 2007 Author Share Posted November 25, 2007 nevermind, it works, had some ftp error if (file_exists('./scripts/' . $formName . '.php')) Quote Link to comment https://forums.phpfreaks.com/topic/78739-solved-validate-include-include_once-require-etc/#findComment-398498 Share on other sites More sharing options...
worldofcarp Posted November 25, 2007 Share Posted November 25, 2007 Another option is to do something like if (@include('whatever.file')) { // was able to include file } else { // wasn't able to include file } the @ suppresses the error message if it isn't there, and it will return true or false if it was able to include the file or not. Quote Link to comment https://forums.phpfreaks.com/topic/78739-solved-validate-include-include_once-require-etc/#findComment-398507 Share on other sites More sharing options...
darksniperx Posted November 25, 2007 Author Share Posted November 25, 2007 hmm, interesting, going to try that out! Quote Link to comment https://forums.phpfreaks.com/topic/78739-solved-validate-include-include_once-require-etc/#findComment-398508 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.