thewindmaker Posted June 5, 2006 Share Posted June 5, 2006 Hi,I am using a ftp server right now but that besides the point.I was wondering if i make a php file with say a menu bar and all its coding and save it to the ftp folder. Can I use that file in part of all of my other pages but just linking it or something like that? So that I won't have to update each page seperatly to add a new link or something instead I could just update that one menu file?ThanksTWM Link to comment Share on other sites More sharing options...
skym Posted June 5, 2006 Share Posted June 5, 2006 include()http://php.net/include/ Link to comment Share on other sites More sharing options...
thewindmaker Posted June 5, 2006 Author Share Posted June 5, 2006 and on the inside of that i just put the file name? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 5, 2006 Share Posted June 5, 2006 That's right, you can include whatever file you want, and you can actually either use parentheses or not:include 'file.txt'; // Works.include ('file.php'); // Works.Check the page that skym linked to for more info. Link to comment Share on other sites More sharing options...
aleksanteri Posted June 6, 2006 Share Posted June 6, 2006 <?phprequire($file);?> Link to comment Share on other sites More sharing options...
thewindmaker Posted June 6, 2006 Author Share Posted June 6, 2006 so i just sae the php file with the contents to the ftp filethen use this codeinclude ('file.php'); (with the file inside the area were it says file.php)and it should work? cause its not for me. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 6, 2006 Share Posted June 6, 2006 That's how it works. If there is a file called "file.php" in the same directory as the file with the include statement, then file.php will be included into the same scope and evaluated. If the file is in a different directory on the same server, make sure you specify the path. If the file is on a different server, you are not able to include PHP code, only HTML.Try using require instead of include and see what the error message says.You can get more information here:http://www.php.net/manual/en/function.include.php Link to comment Share on other sites More sharing options...
thewindmaker Posted June 7, 2006 Author Share Posted June 7, 2006 alright thanks. one more quick questionwhat is the coding to use if the file is in a different directory?thanks again Link to comment Share on other sites More sharing options...
skym Posted June 7, 2006 Share Posted June 7, 2006 Just like you do with paths in HTML.include('path_to_the_file/file.php'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now