|
Mixing PHP & HTML
Introduction
This is a tutorial to teach you a little about mixing PHP & HTML.
PHP Start & End Tags
The PHP parser recognizes 3 different start and end tags. Study the following
code.
<?php //Code ?>
<? //Code ?>
<script language="php"> //Code </script>
Now you are going to use all three sets of code in a script.
<?php echo "This is tag #1.<br />"; ?>
<? echo "This is tag #2.<br />"; ?>
<script language="php"> echo "This is tag #3.<br />"; </script>
Copy the code above and save it as phptags.php, then upload it to your server
to test it out.
Code Cohabitation
Now you will create a script that has PHP code stuck in the middle of you HTML,
and you will learn how these two types of code can peacefully coexist.
<html> <head> <title>First Script</title> </head> <body> <?php echo "Anime Zen Rocks and I'm using PHP!"; ?> </body> </html>
Copy the code and save it as firstscript.php, then upload it to your server
to test it out. Now view the source of the page. Notice that the HTML source
contains only HTML not PHP. The PHP we put was executed.
This is all for this tutorial, maybe some more later.
|