Online
 
Friday, 09 January 2009
 
 
More article:
Related Content:

TUtorial PHP - Basic PHP Syntax
 
Article Index
TUtorial PHP - Basic PHP Syntax
Page 2

Now that you are aware of how PHP scripts are executed, let's discuss how to actually write your first PHP script. All PHP scripts are written in what are called code blocks. These blocks can be embedded into HTML, if desired, and are generally defined by <?php at the start and ?> at the end. Everything outside of these block identifiers will be ignored by the PHP interpreter and instead passed directly back to the Web server to be displayed to the client.

Simple "Hello World" Script
<HTML>
<HEAD><TITLE>My First PHP Script</TITLE></HEAD>
<BODY>
<?php
echo "Hello, world!";
?>
</BODY>
</HTML>



As you would expect, the first three lines of this simple PHP script are ignored and passed directly to the output of the script. The fourth line, however, is executed by PHP, and the string "Hello world!" is printed to the browser, followed by the rest of the ignored HTML text. You have learned your first PHP statementthe echo statement. This statement is the basic method in PHP to display content back to the client, and you'll be using it extensively throughout the book. Also note that, as with other C-style languages, each statement ends with a semicolon.


Tags: Add more tags...,
This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Wallpaper 13
Statistic


Last Post

 
Top! Top!