Basic PHP Syntax
PHP script is starts with <?php and ends with ?>. A PHP script can be placed anywhere in the document.You can start a PHP script with <? and end with ?>.
A PHP file must have a .php extension.
A PHP file generally contains HTML tags, and some PHP scripting code.
The example below sends "How are you" string to browser.
<html> <body> <?php echo "How are you"; ?> </body> </html>Each code line in PHP must end with a semicolon.
Comments in PHP
sinlge line comment : //multiline comment : /* */
<?php //This is a comment /* This is a comment block */ ?>
PHP Variables
A variable can have a short name, like a, or a more descriptive name, like abc.Remeber this for variable in php
- Variables in PHP is start with a $ sign, followed by the name of the variable
- The variable name must begin with a letter or the underscore character
- Variable names are case sensitive (abc and ABC are two different variables)
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- A variable name should not contain blank spaces
Declaring PHP Variable
<?php $txt="Hello World!"; $x=16; ?>
1 comment:
php basics is very useful
Post a Comment