Zephni Posted December 15, 2015 Share Posted December 15, 2015 In my situation I need to check that a php file exists, but I do not want to run any code in that script yet. I have tried the PHP is_file: http://php.net/manual/en/function.is-file.php and the file_exists function: http://php.net/manual/en/function.file-exists.php But both actually run the file. I can tell because of using sessions to test it in the file itself. Is there any way around this? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 15, 2015 Share Posted December 15, 2015 the only way those two functions would run the php code in the file being tested is if you are using a URL to reference the file, instead of a file system path. if these .php files are on the same server as your php script that is testing if they exist, you should be using a file system path. i've got to ask, if this is your code, why do you need to test if a .php file exists? you should already know if it does. Quote Link to comment Share on other sites More sharing options...
Zephni Posted December 15, 2015 Author Share Posted December 15, 2015 (edited) I have been working on a frame work type thing: (http://zephni.com/phpzevelop/howto and GitHub https://github.com/Zephni/PHPZevelop) it needs to check for files (pages) before producing them, if the page does not exist and the page isn't set to receive parameters through the URL then it needs to set the default 404 page instead of the page that does exist. It's hard to explain but I have changed the way it works now so it uses try catch statements to check if the files exist instead of using file_exists methods. Edited December 15, 2015 by Zephni Quote Link to comment 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.