PHP Basics Quiz

Quiz 1 14 questions

Prerequisites for the quiz

  1. PHP Basics
  2. PHP First Program

Are you ready?

14 questions to solve

Instructions
  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
PHP is an abbreviation for what?
PHP is a recursive acronym that stands for PHP: Hypertext Preprocessor. Read more about the very details of PHP at Introduction to PHP.
How to output stuff in PHP?
The echo keyword is used to output text in PHP. Read more at PHP First Program.
Which of the following operators is used to perform the division operation on numbers?
The / (forward slash) operator performs division of two numbers. For example, 10 / 2 returns 5. For more details, refer to PHP Basics — Arithmetic.
What does 5 % 3 evaluate down to?
The % operator returns the remainder when an integer is divided by another non-zero integer. When 5 is divided by 3, the remainder 2 is left off. Hence the correct choice is (C). For more details, refer to PHP Basics — Arithmetic.
How to create a variable called 'x' in PHP, holding the value 10?
For more details, refer to PHP Basics — Variables.
How to obtain input from the user in PHP?
The fgets() function in PHP allows us retrieve input from the user, or more specifically, from standard input. For it to operate, it requires a reference to standard input and that's provided as an argument via the STDIN constant.

Hence, the correct choice is (A). For more details, refer to PHP Basics — Standard Input.
What is meant by string concatenation?
String concatenation means to join together two strings into one single string. This goes with choice (B). For more details, refer to PHP Basics — Strings.
A statement and an expression is the same thing. True or false.
Statements and expressions are two completely different things, and this goes with choice (B). For more details, refer to PHP Basics — Statements and Expressions.
Which of the following best fits with the idea of an expression?
An expression is a unitary piece of code that resolves down to a given value. This goes with choice (B). For more details, refer to PHP Basics — Statements and Expressions.
Which of the following definitions best describes a string in PHP?
A string is a simply just sequence of textual characters. This goes with choice (C). For more details, refer to PHP Basics — Strings.
What does the following code output?
<?php

echo (5 * 5 + 5) * 5 - 5;

?>
This is more of a mathematical question than a programming one. First the bracket is resolved, wherein first the multiplication is resolved. Next, the second multiplication is done followed by the last addition to give the answer 145. For more details, refer to PHP Basics — Arithmetic.
What does the following code output?
<?php

echo 'Hello\nWorld!';

?>
When a string in PHP is denoted via single quotes (''), whatever is written inside it is represented as is in memory. In the code above, \n inside the string does not represent a newline — instead it just represents the two characters \ and n. Hence, the correct choice is (B). For more details, refer to PHP Basics — Strings.
Which of the following denotes a string?
Both, choice (A) and (B) are perfectly legal ways to create a string in PHP. Hence the correct choice is (C). For more details, refer to PHP Basics — Strings.
Which of the following operators is used to concatenate strings in PHP?
The . operator is used to concatenate together two strings. This goes with choice (B). For more details, refer to PHP Basics — Strings.