When everyone thinks of PHP, they automatically think of a advanced programming language that is difficult to use and understand. However with the simpler functions of PHP you can create some very dynamic and interesting pages. What I will be showing you in this guide is a easy way to create a page that uses both HTML and PHP in a simple and easy way. In this guide I will not be going very deep into the details of PHP coding, if after learning these simple steps that anyone with basic HTML knowledge can do then you may want to consider looking at www.w3schools.com where there is more in depth knowledge regarding this programming language.
Okay to start you will need to create a folder on a Data drive like your C drive which most PC’s have you can name it simply “php”. After this inside of the folder create another folder called “include”. You file structure so far will look something like this “C php include” after this is completed you will need to create a file called index.php and it will need to be directly underneath your “C php” folder. Now you will begin to code your first PHP file, at this point all you will do is code the page the same as a HTML page. You will not as of yet need anything different, so open your page with standard codes:
- lt; html gt; lt; title gt; This is my first PHP page lt; /title gt;
- lt; head gt; META TAGS HERE lt; /head gt;
- lt; body gt;
Okay lets stop here and look at our next step. What we will be doing is creating a file that will be used for your menu and header, it will basically comprise the entire top of your page. Create a new file underneath “C php include” and name it “header.php”, at this point you would continue your coding with regular HTML where you left off. You will NOT need to escape your quotes, if you are not sure what this is then ignore it. For instance at this point we would be able to put a regular HTML based menu in this file, I have placed Spaces in this code to make it easier for it to show up. If you understand basic HTML you will be able to recognize and remove them without any issues. So header.php will look like this without the spaces.
- lt; a href = ” index.php ” gt;Home lt; /a gt;
- lt; a href = ” contactus.php ” gt;Contact Us lt; /a gt;
- lt; a href = ” products.php ” gt;Products lt; /a gt;
- lt; a href = ” about.php ” gt;About Us lt; /a gt;
Great job now we can move on to the next step so that we can see some results! Re-open your index.php file and we are now going to use a simple php command to call the file so that it will be viewed in your web browser seamlessly. The following is the command that you will enter on the next available line in your index.php file. Once again spaces have been added for viewing purposes, in this command the ” lt; ” and ” ? ” and ” php ” will all be one word and the semi colon at the end of the first line will not have a space. Be sure to place your ending remark on the next line available. This will tell the browser to stop reading the PHP code.
lt; ? php include ‘C include header.php’ ;
Cool Now save your file, You will at this point be able to continue with your HTML coding and be able to place whatever would be normally underneath your menu. Why is this important??? Because now all you need to do is update ONE file and your menu is done on every page in your site! No longer are the days when you have to touch every web page on your site so that you can update on single link! After you are finished with the content of your page then we will be able to include a footer in the same fashion, this way we can update it on the fly as well. Get creative and work with these tips, you can also use this method to put menus up and more!Your footer would look like this just make sure to create the footer.php file and place it in the include folder and your done:
lt; ? php include ‘C include footer.php’ ;
At this point you have 2 different options, by either closing the HTML in your footer.php file or by closing it on your index.php file. I personally recommend closing your HTML code in your footer.php. This way all you have to worry about is your content pages. Congratulations you have successfully made your first PHP page!
These are some of the helpful tips that you can avail while trying out for PHP, which is quite interesting to make in HTML format because it has numerous measures to bank upon and a memorable quotation like a preventivo sito web roma that makes the website look unique.