HI! I want to know PHP Web Developing.. i can design easly in html but it is very hard to change in every page like in my web pakistans.com i put iframe as a header so its easy to edit but let me know how to make a single header for all pages in php? Thanks in advance
Well, you have to create a header.php file for example... Put the header content inside it. Then, in the index page, write: <?php include_once('header.php'); ?> PHP:
Yeah the above method is absolutely best approach. Just make a common file and use it in every page by including it!
Or you can learn smarty its best as the code is separated from design which makes your future site maintenance easier www.smarty.net
I have also worked on smarty. Its reducing the complexity while debugging. It will separate the design with the functionality. So we can easily differentiate when error comes.
Guys thanks for help but let me know if my header is in public_html and may index in some other directory then what whould i do for it?
Can do a coupla things. The easiest method will be to find out the full path to the file and use it( I would set it as a variable or constant). This is usually something like /home/usrname/public_html/ . The quick method is to learn to use the directory structure. Let's say you have /public_html/header.php and there is /public_html/docs/index.php . To include the header you would put this: include "../header.php"; The ../ means go up one level in the file system to find the file. You can keep piling these on if you have to go up multi levels. The first method is really best since you would do something like : $path = "/home/usr/public_html/"; This should be in a settings file included before the script starts. When you want to call the header.php file, you would just use the following: include $path . "header.php"; It's better because you don't have to adjust it based on where the calling file is located.