dfqaz Posted May 15, 2011 Share Posted May 15, 2011 im writing php application in windows 7 using apachi . iwant to include php file to another php file. This is the code. test.php ------------- before <?php require_once 'footer.php'; ?> after fotter.php -------------- test 1 ------------------------- test2 when I include the above footer.php into test.php file I got the following result. before <?php require_once 'footer.php'; ?> after Could you please tell me wher i goes woring? Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/ Share on other sites More sharing options...
fugix Posted May 15, 2011 Share Posted May 15, 2011 im not really following what you are trying to tell us here Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215551 Share on other sites More sharing options...
dfqaz Posted May 15, 2011 Author Share Posted May 15, 2011 including() function or require_once() function is not working on my pc. Im working on windows 7. Is that my problem? All php functions and apachi is working on windows 7? Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215555 Share on other sites More sharing options...
fugix Posted May 15, 2011 Share Posted May 15, 2011 what are your results? Do you receive any errors with the function or is it not including the script Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215572 Share on other sites More sharing options...
anupamsaha Posted May 15, 2011 Share Posted May 15, 2011 Put the following at the top of your PHP code and see what errors are you getting: error_reporting(E_ALL); ini_set("display_errors", 1); Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215599 Share on other sites More sharing options...
fugix Posted May 15, 2011 Share Posted May 15, 2011 also, might be because you are not using a relative path...are you using a localhost server? try this <?php require_once 'example/dir/footer.php'; ?> using the full path to the file Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215600 Share on other sites More sharing options...
dfqaz Posted May 15, 2011 Author Share Posted May 15, 2011 @anupamsaha when I type ur code in top of my code. It removed code Put the following at the top of your PHP code and see what errors are you getting: error_reporting(E_ALL); ini_set("display_errors", 1); Thanks! Thanx. When I insert ur code I got only the `before` and `after` words without <?php require_once 'footer.php'; ?> . But it is not included my footer file. This is my code agin... test.php before <?php require_once 'footer.php'; ?> after footer.php test 1 ------------------------- test2 results ahould be before test 1 ------------------------- test2 after Please help me... Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215648 Share on other sites More sharing options...
wildteen88 Posted May 15, 2011 Share Posted May 15, 2011 In order to run PHP code on your computer you need to install a http server (IIS or Apache) which is configured with PHP. Simply just loading test.php directly into your web browser will not work. If you have installed a Server that is configured with PHP then make sure you are saving the php files in your servers root folder and going to http://localhost/test.php to run it. Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215651 Share on other sites More sharing options...
Sanjib Sinha Posted May 15, 2011 Share Posted May 15, 2011 Wildteen is correct. Your code is perfect but the main problem lies in server side where it can not read php. To test it in your Windows OS, you may better try WAMP it'll take less than 5 minutes. Quote Link to comment https://forums.phpfreaks.com/topic/236435-php-require_once-not-working/#findComment-1215657 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.