Installation and preparation for work
- PHP is an interpreted language, which means that it cannot function without an interpreter;
- Most of the PHP syntax is identical to the C language syntax;
- In the most frequent cases, PHP is used in the production of HTML pages, respectively of dynamic web applications;
- PHP cannot render HTML pages without a web server;
- PHP can run on different web servers;
- PHP code can be written with any text editor;
- For a document to be sent to PHP, it must have a .php extension;
- In order for the script inside the document to be started, it must be enabled through the PHP tags: <?php ?> or <? ?> .
- In the browser, animations cannot be made with the help of PHP.
Data types
- Data types are classified into simple, complex and special types;
- The simple data types are: integer , float , string and boolean , the complex types are: array and object , and the special ones: Resource and NULL ;
- Strings contain collections of data, where the address of the beginning of this collection is stored in the variable;
- PHP is able to automatically convert simple types;
- Simple type cannot be converted to complex type;
- There are several types of notation of numeric types: octal, hexadecimal, decimal…
variables
- In PHP, variables must contain the $ sign ($myVariables) in front of the name.
- In PHP, variables must not have a name where the first character is a number or a special character ($1myVariables – not correct, $%myVariables – not correct).
- In PHP, constants must not have a $ sign in front of the name. define(“PI”, 3.14).
- In PHP, constants can be of any type (which is supported by the language).
operators
- Operators are used to assign values, compare two values, associate expressions or perform arithmetic operations on values.
- There are several types of operators. The most important are: comparison operators, logical operators, arithmetic operators and assignment operators.
- The comparison operators are: ==, !=, <, >, <=, >=, ===, !==; the assignment operator is: =; the logical operators are: &&, || , and the arithmetic operators are: +, -, /, *, %.
- Assignment can be performed by value or by reference.
- When applying the increment or decrement operator, it matters whether the operator comes before or after the variable.
- When using the arithmetic operator, PHP will perform the conversion to the appropriate types if possible.