Gen. partnerAlgotech

PHP Keywords

The list of keywords is good to know because they have special meanings in PHP and cannot always be used for everything. For example, the name of a class must not be the same as one of the existing keywords.

|
April 10, 2021

Almost all programming languages consist of keywords, which are special expressions of the language that have a special meaning.

An example of a keyword is the word string, if or echo.

It is important to note that keywords (sometimes also commands) are not functions, so echo, for example, is not a function either.

The list of keywords is good to know because they have special meanings in PHP and cannot always be used for everything. For example, the name of a class must not be the same as one of the existing keywords.

Example parse error

When attempting to process a class named String, a Parse error occurs because PHP does not know if it is a class name or a data type:

This is wrong:

class String
{
// ...
}

List of keywords

Updated keyword list for PHP 7.1:

and, or, xor, for, do, while, foreach, as, return, die, exit, if, then, else, elseif, new, delete, try, throw, catch, finally, class, function, string, array, object, resource, var, bool, boolean, int, integer, float, double, real, string, array, global, const, static, public, private, protected, published, extends, switch, true, false, null, void, this, self, struct, char, signed, unsigned, short, long

Loading comments...

Stay in the loop

Subscribe to our newsletter and get the latest cybersecurity news delivered straight to your inbox.

Your data is safe. You can unsubscribe from the newsletter at any time.