Introduction
A statement is a piece of code that instructs PHP to do something. A statement may compute a value and store it in memory. There are different types of statements in PHP. Function calls, variable assignment, loops, and conditional statements.
Simple statement
- <?php
- //an expression statement
- 2+3;
- //another expression statement
- print("PHP!");
- // a control statement
- if( 3 > 2)
- {
- //an assignment statement
- $a = 3;
- }
- ?>
The first statement is the addition of two numbers. It produces the output. The second prints a string to the browser. The third decides whether to execute a block of code based on an expression. PHP includes many types of statements. Some are simple, stand by themselves, and compare well with functions.
Data types
PHP has eight diffrent types of values or datatypes. The first five are basic: integers, floating-point, string, booleans, null. Two other are composed of the basic types or composite types. They include arrays and objects. Additionally the resource type denotes a non-native type such as open file or a databse connection.
Integers
Integers are whole numbers. The range of integers in PHP is equivalent to the range of the long datatype of C language. PHP allows us to write integers in three ways: decimal, octal, hexadecimal. Decimal digits are the ordinary base -10 numbers. Octals are base- 8 numbers consisting of a sequence of digits from 0 to 7 prefixed by a leading zero. Hexa-decimal are 16-base numbers begin with 0x, followed by a sequence of digits or letters from A to F.
Floating Numbers
Floating point numbers represent numeric values with decimal digits, which are equivalent to the range of the double data type of the C language. It is also called real numbers or doubles. The range and accuracy of real number varies from one platform to another.
String
Web applications usually move text around more often than they make complex mathematical calculations. PHP intercepts characters inside single quotes as is: Each character between quotes becomes one character in the string. \"- Double quotes,\\- Backslash character, \n- New line, \r- Carriage return, \t- Horizontal tab.
Boolean and Null
It contains only two values, true and false. The control statements use boolean values to decide whether to execute blocks of code and the comparision operator.
Null is a special type that stands for the lack of value. It is typically used to initialize and reset variables or to check whether or not a variable is initialized. Null constant is used to unset a variable.

Join the conversation! Your thoughts help the community grow.