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

Website PHP - Basics of PHP
 

PHP - PHP Language Programing 

PHP operates with PHP mode turned off, which means that PHP will consider the content to be plain text (i.e., not PHP code) unless PHP mode has been enabled. This method of parsing means that the PHP elements of a script are "code islands"standalone chunks of code that can work independently of the HTML "sea" around them.

PHP scripts are generally saved with the file extension .php to signify their type. Whenever your web server is asked to send a file ending with .php, it first passes it to the PHP interpreter, which executes any PHP code in the script before returning a generated file to the end user. The basic unit of PHP code is called a statement, and ends with a semicolon to signify it is a complete statement. For clarity, one line of code usually contains just one statement, but you can have as many statements on one line as you want. These two examples do the same thing:

 <?php
// option 1
print "Hello, ";
print "world!";
// option 2
print "Hello, "; print "world!";
?>
PHP purists like to point out that print is technically not a function and, technically, they are correct. This is why print doesn't require brackets around the data you pass to it. Other language constructs that masquerade as functions (and are herein referred to as such for the sake of sanity) include array, echo, include, require, return, and exit.

You can use parentheses with these constructs, and doing so is harmless:

 <?php

print("Hello!");
?>
Although on the surface, print and echo appear the same, they are not. The print construct behaves more like a function than echo because it returns a value (1). However, echo is more useful because you can pass it several parameters, like this:
 <?php
echo "This ", "is ", "a ", "test.";
?>
To do the same using print, you would need to use the concatenation operation (.) to join the strings together, rather than a comma. If you have several things to print out, as in that example, then echo is preferred for the sake of clarity

Read More PHP:PHP - Functions | PHP - Including Other Files | PHP - Comments Tutorial | PHP - Example Whitespace | PHP - Variables of PHP | PHP - Basics of PHP | PHP Abnormal Script | PHP - Output Control 

Links to this article:"PHP - Basic of PHP"

 

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

Mobile Wallpaper 184
Statistic


Last Post

 
Top! Top!