-
Statements: PHP code is composed of statements, each ending with a semicolon ';'
.
-
Whitespace: Whitespace (spaces, tabs, and line breaks) is generally ignored in PHP code, except within string literals. However, it's important for code readability and organization.
-
Comments: PHP supports single-line comments starting with //
and multi-line comments enclosed between /*
and */
. Comments are ignored by the PHP parser and are used for code documentation and explanation.
-
Variables: Variables in PHP start with the dollar sign $
, followed by the variable name. Variable names must begin with a letter or underscore, followed by any combination of letters, numbers, or underscores.
-
Data Types: PHP supports various data types including strings, integers, floats, booleans, arrays, and objects. Variables in PHP are dynamically typed, meaning their data type can change during execution.
-
Strings: Strings in PHP can be enclosed in single quotes ' '
or double quotes " "
. Double-quoted strings allow for variable interpolation, meaning variables within the string will be evaluated.
-
Keywords: PHP has a set of reserved keywords that cannot be used as identifiers (e.g., variable names, function names). Some examples of keywords include if
, else
, while
, function
, class
, and return
.
-
Semicolon: Each statement in PHP must end with a semicolon ;
. Omitting the semicolon at the end of a statement will result in a parse error.