|One of the features that make PHP such a popular language is that you can mix your HTML and PHP code together on the same page. There are just two simple rules you need to remember. You will need to change the extension on the end of the name of the webpage. Secondly, wrap your PHP code inside the opening and closing PHP tags.|
You will need to change the extension on the name of your webpage from .html to a PHP extension. Your web host can tell you which PHP extension to use for the server you are on. First check the online documentation. If the answer is not there you can email your web host. Usually the extension will be either .php or .php3.
Example: mywebpage.html ------> mywebpage.php3
You will enclose all of your PHP code between opening (<?php) and closing (?>) tags. This is how the server can tell the HTML and the PHP code apart.
Next we will add some PHP code that will print either "Good Morning" or "Good Evening" depending on the time of day that the webpage is viewed. If the hour of the day is before noon, then "Good Morning" will be printed. If the time is noon or later, then "Good Evening" will be printed. I know we haven't discussed the PHP code in detail, but take a look at it anyway. I bet you can figure out how it works. Then add the PHP code to the webpage.
Finally add the code below to finish the rest of the message and the end of the webpage using HTML. Click here to view the entire code.
Now save your webpage. Call it "sample2.php3" (or sample2.php) and put the file in the following location.
Finally we will test the webpage. Open the Sokkit Control Panel and RIGHT click on the View Site button. Choose "Open in New Window" from the pop-up list. This will cause the sokkitdefault.html webpage to be displayed in the new window. You should see a message saying "This site is powered by Sokkit 3.4". Now go to the url address line in the web browser. It should say http://localhost/. To test your webpage, add sample2.php3 at the end of this and click Enter. You will see a white page with the following.
Good Morning (Good Evening)
Welcome to my website.