Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
The PHP programming language


1. The PHP programming language

2. PHP
PHPPHP is a scripting language that is often used for server side creation of web pages. But PHP can be used in command line mode.

PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world. From the PHP web site at https://www.php.net/ .

For installation details, see PHP .

3. Versions
The current version is 7 though 5 is still popular. Version 6 was never released.

Version 7 adds more Unicode support.

4. Design
As a programming language designed for non-programmers, PHP has a large number of quirks and design defects.

PHP is very usable despite having many quirks and design defects, but those quirks and design defects can be very annoying.

5. Rasmus Lerdorf
PHP was created by Rasmus Lerdorf in 1994.

PHP started out standing for "Personal Home Page" but now stands for "PHP Hypertext Processor". (a self-referential definition)

6. Startup
PHP started as a server side web page development system in 1994, hooking into the CGI (Common Gateway Interface) model.

PHP is designed to pass text through to a web page but have interspersed PHP code that customizes what is inserted.

7. Command line mode
PHP can be used in command line mode as a general programming language.

8. PHP features
Some PHP features, or quirks, include the following.

Note: As with many languages, I pick a subset of the language that works as expected and then use that subset, avoiding as many bad parts as needed.

This is not as easy in PHP as in other languages.

9. Integers
If an integer overflows, most languages ignore the error (cycling around to the opposite end of the integer range) or raise an exception.

PHP converts the integer to a float (with a bigger integer range) and continues execution, without a way to easily detect that it has happened.

10. Comparisons
The equality operator "==" and "!=="have many quirks.

Instead, one should use "===" or "!===".

PHP does not have true and false types (that act as expected) so one may want to use 0 for false and 1 for true appropriately.

11. Names
Variable names are case-sensitive.

Function and class names are not case-sensitive.

12. Variable names and scope
Variables are not declared but created on first use. If a variable that does not exist is used, it is created with a null value and then used.

Variable names start with a dollar sign (even though an analysis of the program could determine which identifiers are variables).

13. Variable scope
Global variables cannot be accessed inside a function unless they are declared there as global.

Without the global declaration, any global variable is considered a local variable, created locally, given a null value, and used.

Module variables need to be declared as global to access them, even at the top level of modules and programs.

14. Class and module references

15. Lists and dictionaries
PHP lists (arrays) and dictionaries (hashed arrays) are somewhat similar and can be easily confused.

When used, these structures do a copy rather than update the list or dict, so one must be very careful about the order in which updates are made to lists and/or dicts.

16. Sorting
PHP has (at least) 13 functions for sorting an array in various ways. Why so many?

17. Functional arguments
Functions as arguments is handled by passing the function name as a string and doing appropriate processing or calls.

18. End of page

19. Acronyms and/or initialisms for this page