PHP is a server side scripting language
PHP script is written within <?php ….. ?>
When browser request a php document, the web server calls PHP processor, and the PHP processor interprets the script and sends the output of the script back to the web browser.
The output of the PHP script is always an HTML. The client requesting the PHP script will never see the PHP code in the web browser.
PHP scripts are saved using .php file extension
PHP is a purely interpreted language, however recent developments of PHP performs some precompilation.
PHP is case sensitive
PHP statements are terminated with semicolon
Braces are used for compound statements or body of the control statements and functions
PHP uses dynamic typing
Variables are not declared using type
The type of the variable is set whenever the variable is assigned a value
Variable in PHP begin with a dollar ($) character followed by variable name
An unassigned variable has a value NULL and is known as unbound variable.
If unassigned variables are used in an expression, then its value is coerced to 0 if the context is number and coerced to empty string if its context is a string
To check whether a variable has a value, IsSet function is used. This function takes variable as an argument and returns true if the variable has a value and false if variable is unassigned.
The type of the variable can be determined in two ways:
- Using gettype function:
Takes variable as parameter and returns string containing type of the variable
- Use type testing functions: which takes variable as parameter and returns Boolean value.
is_int(), is_integer(), is_long(), id_double(), is_float(), is_real(), is_bool() and is_string()
PHP allows comments in three different ways:
Single line comments are specified using # or //
Multiline comments uses /* …… */