php_and_html
Table of Contents
PHP and HTML
- October 18
Don't forget, you can make a PHP web server and look at it using your web browser if you use the following command:
php -S 127.0.0.1:5000
You can change 5000 to any number you like, but usually between 5000 and 10,000.
Example Webpage
Let's make a PHP file that creates a wepbage, by echo-ing some HTML.
<?php echo " <p>Chip wants to make some biscuits. He has no sugar.</p> <p>He goes to a supermarket. He gets some crisps.</p> <p>He goes to a small shop. He gets a book.</p> "; ?>
Story Webpage
You can use anything in PHP when you are running in a web-page, but you should output HTML for the browser.
<?php $name1 = "Ian"; $name2 = "Erica"; $animal = "Dino"; echo "<h1>This is the story of {$name1}.</h1>"; echo "<h2>Chapter 1: The beginning</h2>"; echo "<p>One day, {$name1} was bitten by a "; echo "<strong>{$animal}</strong>. "; echo "The {$animal} was magic, and {$name1} became "; echo "<em>{$animal}{$name1}.</em></p>"; echo "<p>The next day, {$animal}{$name1} saw {$name2}. "; echo "{$name2} said, why are you a {$animal}? "; echo "{$name1} said, \"I don't know.\" "; echo "The end!</p>"; ?>
Homework
Make your own funny story.
php_and_html.txt · Last modified: 2024/10/06 05:21 by appledog