PHP
0Loading crowd target
0Loading crowd target
7correct to beat the crowd
50 free PHP trivia questions with answers — science & nature quiz, new questions added Oct 2026.
PHP was never planned as a programming language. It grew out of one developer's web tools in the 1990s, picked up a strange name and an even stranger mascot along the way, and ended up running a huge share of the websites people visit every day. This quiz covers the ground a learner meets early and an examiner likes to probe: basic syntax and operators, arrays and the functions that work on them, variable scope and the built-in request variables, classes and objects, plus the history, tools and well-known projects around the language. It suits students revising for a course, developers brushing up before an interview, and anyone curious about the code behind so much of the web. Every answer comes with a short explanation, so a wrong guess still teaches something.
30 of 50 questions with answers and explanations. Play the quiz
Q 01Which programmer started PHP as a handful of small programs written to help maintain his own website?
Rasmus Lerdorf
Rasmus Lerdorf never meant to invent a language: he has said he simply kept adding the next logical step to his web tools.
Q 02PHP is now a recursive acronym for PHP: Hypertext Preprocessor, but which phrase did its letters originally abbreviate?
Personal Home Page
Personal Home Page Tools was the name of the first public release, which its author announced on a Usenet newsgroup in June 1995.
Q 03PHP's mascot was born when Vincent Pontier noticed the letters PHP resembled which animal seen from the side?
Elephant
An elephant, nicknamed the elePHPant, has been PHP's mascot since 1998, and its plush-toy versions are now collectors' items, some of them extremely rare.
Q 04Which PHP content management system did Matt Mullenweg and Mike Little launch as a fork of b2/cafelog?
WordPress
WordPress got its name from Christine Selleck Tremoulet, a friend of Mullenweg, and has grown from a blogging tool into software for shops, forums and whole websites.
Q 05Which social network created HipHop, a tool that turned its PHP code into C++ to ease the load on its servers?
Facebook retired HipHop in early 2013 in favour of HHVM, its own virtual machine, partly because the older tool was difficult to deploy.
Q 06Which symbol must come before every variable name in PHP, followed by a letter or an underscore?
Dollar sign
A dollar sign opens every PHP variable, and the names are case-sensitive, so $age and $Age are two separate variables.
Q 07PHP error messages long called the :: operator Paamayim Nekudotayim, a name taken from which language?
Hebrew
Hebrew supplied the name when the team rewriting PHP's core for version 3 picked it, and the baffling term stayed in error messages until PHP 8.
Q 08Which bluntly named PHP function is an exact alias of exit, ending a script the moment it runs?
die
die does exactly what exit does: hand it a string and PHP prints that message just before the script stops.
Q 09In the LAMP stack, L is Linux, A is Apache and P can mean PHP; which database originally supplied the M?
MySQL
MySQL took the M when a German magazine coined LAMP in 1998, although its community fork MariaDB now often fills the same slot.
Q 10PHP 7 added the three-way comparison operator <=>, which the PHP manual itself lists under what nickname?
Spaceship
Spaceship returns a negative number, zero or a positive number depending on which side is larger, exactly the answer a sorting callback has to give.
Q 11Which PHP output statement, unlike print, accepts several comma-separated arguments and returns no value?
echo
echo is built into the language itself rather than being a true function, which is why it works without parentheses and cannot be called through a variable.
Q 12Which character joins two strings together in PHP, where JavaScript and Python would use a plus sign?
Dot
A dot glues strings together in PHP, and its partner .= appends text to the end of an existing variable.
Q 13A block of PHP code inside an HTML file opens with <?php; which two-character tag marks where it ends?
?>
?> is best left off a file that holds only PHP, because stray spaces or blank lines after it would be sent to the browser by accident.
Q 21Which PHP function returns the number of elements in an array and has sizeof as an alias?
count
count can also add up the elements of nested arrays in a single call when given the COUNT_RECURSIVE flag as a second argument.
Q 22Which kind of PHP array uses meaningful string keys such as 'email' in place of a numbered sequence?
Associative
Associative arrays are not a separate type: PHP draws no line between them and numbered lists, so one array can mix text keys and integer keys.
Q 23Since PHP 5.4, which pair of characters can create an array in place of the longer array() syntax?
Square brackets
Square brackets became a shorthand for array() in PHP 5.4, although the core developers had voted the same idea down in 2008, so [1, 2, 3] now builds a list directly.
Q 14Which delimiters around a PHP string cause variable names inside it to be replaced by their values?
Double quotes
Double quotes make PHP expand variables and escape codes such as \n, while the same text in single quotes is output exactly as typed.
Q 15PHP jumped straight from version 5 to version 7 after the abandoned PHP 6 failed to deliver native support for what?
Unicode
Unicode was to be stored internally as UTF-16, but the conversions hurt performance and too few developers understood the changes, so the effort was abandoned in 2010.
Q 16Which PHP comparison operator is true only when two values are equal and also of the same type?
===
=== is called the identical operator, and it exists because the looser == treats the number 5 and the text '5' as equal.
Q 17Which PHP loop works only on arrays and objects, visiting every element in turn without a counter variable?
foreach
A foreach loop hands over each value in turn, or each key and value together, and raises an error if it is pointed at anything other than an array or object.
Q 18What does the PHP manual call the ?? operator, which supplies a fallback when a variable has not been set?
Null coalescing
Null coalescing arrived in PHP 7 to replace a wordy ternary check: $name ?? 'guest' yields the fallback without raising any notice or warning.
Q 19Which symbol, placed in front of a PHP expression, silences the warnings that expression would otherwise generate?
At sign
An at sign is PHP's error control operator, though since PHP 8 it can no longer silence the critical errors that stop a script.
Q 20PHP's execution operator, deprecated in version 8.5, runs text wrapped in which characters as a shell command?
Backticks
Backticks behave exactly like a call to shell_exec(): the command's output comes back as a string instead of being printed.
Q 24Which PHP function splits a string into pieces at every separator, with an optional limit on how many come back?
explode
explode turns a line such as 'a,b,c' into a three-element array, and its opposite number, implode, glues the pieces back together.
Q 25Which function for PHP arrays removes the last element and returns it, shortening the collection by one?
array_pop
array_pop treats an array like a stack of plates, taking from the top; its mirror image array_shift removes the first element instead.
Q 26Which PHP function tells whether a value exists in a list, with an optional strict mode that also compares types?
in_array
in_array uses loose comparison unless its third argument is true, which is why careful code switches strict mode on to avoid surprise matches.
Q 27Which function joins two or more PHP arrays into one, renumbering any numeric keys from zero?
array_merge
array_merge appends each list to the one before it, and when two inputs share a string key the later value overwrites the earlier one.
Q 28Which PHP function sorts an array by its keys in ascending order while keeping each key tied to its value?
ksort
ksort belongs to a family of one-letter variations: asort orders by value but keeps the keys, and krsort runs the key order in reverse.
Q 29Which PHP function builds an array from a start and an end value, so that passing 1 and 5 yields five numbers?
range
range also works on letters, so asking for 'a' to 'e' produces the first five letters of the alphabet, and a third argument sets the step size.
Q 30Which function runs a callback on every element of one or more PHP arrays and returns the results?
array_map
array_map returns a brand-new array, and given several inputs it feeds the callback one element from each of them at a time.