07-08-2009, 05:28 PM
Getting started with php
Getting started in Php
Lets get to know the common, useful functions of Php...
A php file uses an extension of : .php | Example : index.php
When you start a php file you will always use "<?php" to start the script, and to close the script you use "?>".
Example :
Php files normally contain HTML tags, just like HTML files, and some php scripting code.
Here is an example of a simple Php script which sends the text "Hello World" to the browser.
Example :
Each php code line ends with a semicolon ";" this is used to separte one set of instructions to another.
There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".
Note: The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.
Php Comments
Php comments can be quite important, obviously to help you remember and guide you, but if you release a php file, you normally write about each part of the script.
To start a comment beside/above/below the script you must use "//"
If you are doing more than one line comment you must use "/*" followed by "*/"
Example :
Enjoy, and make sure you don't miss out on the next tutorial..
Getting started in Php
Lets get to know the common, useful functions of Php...
A php file uses an extension of : .php | Example : index.php
When you start a php file you will always use "<?php" to start the script, and to close the script you use "?>".
Example :
PHP Code:
<?php
?>Php files normally contain HTML tags, just like HTML files, and some php scripting code.
Here is an example of a simple Php script which sends the text "Hello World" to the browser.
Example :
PHP Code:
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
Each php code line ends with a semicolon ";" this is used to separte one set of instructions to another.
There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".
Note: The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.
Php Comments
Php comments can be quite important, obviously to help you remember and guide you, but if you release a php file, you normally write about each part of the script.
To start a comment beside/above/below the script you must use "//"
If you are doing more than one line comment you must use "/*" followed by "*/"
Example :
PHP Code:
<html>
<body>
<?php
// This is a single line comment
/*
This is
a comment
on more than
one line
*/
?>
</body>
</html>
Enjoy, and make sure you don't miss out on the next tutorial..
