ballouta Posted February 24, 2009 Share Posted February 24, 2009 Hello I have a big menu generated from my DB using a PHP code... every time i modify this menu i have to copy all the menu code to all other pages which is waste of time. is there anyway to put this PHP code in a separate time and 'echo' its content whenever i want from another pages? How? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/146747-including-a-menu-code/ Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 include would be what you are after Quote Link to comment https://forums.phpfreaks.com/topic/146747-including-a-menu-code/#findComment-770422 Share on other sites More sharing options...
ballouta Posted February 24, 2009 Author Share Posted February 24, 2009 so I put my menu code in a file e.g. menu.php and i use this line of code to include it in another pages? include('menu.php'); But how do print this file content in the page included? Quote Link to comment https://forums.phpfreaks.com/topic/146747-including-a-menu-code/#findComment-770441 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 so I put my menu code in a file e.g. menu.php and i use this line of code to include it in another pages? include('menu.php'); But how do print this file content in the page included? All the print statements should be in menu.php, the include will execute the code in the menu.php file like the code was on that page to begin with. Give it a try and mess around with it to see how it works. Quote Link to comment https://forums.phpfreaks.com/topic/146747-including-a-menu-code/#findComment-770449 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.