sngumo Posted May 28, 2008 Share Posted May 28, 2008 Hi, I would like to know whether there is a sure way of using the 'include' command so that I don't have to put absolute paths for calling of any files? Alternative is there any other way of directing the PHP parser to a different file if (e.g.) an 'if' condition is executed and the result takes the parser to another file. Example if(storesession($email,1)==TRUE) { include ('../home.php');// This doesn't work even though the file is on the upper level. } else { echo "Create Session Error<br/><br/>"; echo mysql_error(); } Also I need to know whether using the header () command will send the parser to a whole page all together since I am using a template based site i.e. all my pages load on the index page. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/107625-solved-a-sure-way-of-using-the-include-command/ Share on other sites More sharing options...
MadTechie Posted May 28, 2008 Share Posted May 28, 2008 i'm slightly confused by your question and include, includes a file into the code, so if that file contains php code that code will be parsedm, as if it was in that file directly.. so yes you can use an if statement, yes headers will be parserd (that means if you use Header('location: xyz.com') your be redirected to xyz.com it will not read inn xyz.com. Quote Link to comment https://forums.phpfreaks.com/topic/107625-solved-a-sure-way-of-using-the-include-command/#findComment-551640 Share on other sites More sharing options...
sngumo Posted May 28, 2008 Author Share Posted May 28, 2008 Thanks for your reply Just to clarify, the home.php within the include command isn't located and therefore an error is generated. I was asking whether there was one sure way of inserting a path in the include command which will enable the parser to locate the file I am referencing without having to put in an absolute path. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/107625-solved-a-sure-way-of-using-the-include-command/#findComment-551658 Share on other sites More sharing options...
trq Posted May 28, 2008 Share Posted May 28, 2008 You might take a look at both set_include_path() and get_include_path(). Also, the $_SERVER['DOCUMENT_ROOT'] variable can come in handy for locating your root. Quote Link to comment https://forums.phpfreaks.com/topic/107625-solved-a-sure-way-of-using-the-include-command/#findComment-551662 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.