Pages

Friday, October 29, 2010

Helpful PHP Hints

You can combine PHP with HTML, like so:
<html>
<body>

<font face="Arial,Helvetica">

<?php
   print "my first PHP script!";
?>

</font>

</body>
</html>
As long as you still name the file with a .php extension, the server will check the code for <?php ?> tags, interpret them, and send them along to the browser along with the HTML code, so that when it has loaded it just looks like a regular HTML page.



You can add comments to your PHP code like so:
<?php
   // print some text
   print "my first PHP script!";
?>
Everything on a line beginning with two slashes (//) will be ignored by the server. Comments serve as reminders, and are useful when you go back to the code months later to edit it. If you have comments that span over more lines than one, use the following comment tags:
<?php
   /*
   print some text
   this is a comment
   over more than one line
   */
   print "my first PHP script!";
?>

0 Comments:

Post a Comment