Font size
WorksheetsPHP Quiz
Total questions: 69
Worksheet time: 40mins
Who developed PHP?
Linus Torvalds
James Gosling
Rasmus Lerdorf
Guido van Rossum
In which year was PHP developed?
1984
1994
2004
2014
What is PHP primarily used for?
Mobile applications
Server-side scripting
Desktop software
Operating systems
PHP is embedded in which type of pages?
HTML
XHTML
XML
JSON
What does PHP stand for?
Personal Home Page
PHP Hypertext Preprocessor
Preprocessed HTML Pages
Programmable Hyperlinking Protocol
Which of the following is a feature of PHP?
Poor support for form processing
Limited to MySQL databases
Good support for form processing
Cannot interface with databases
PHP can interface with a wide variety of databases.
True
False
What are the two ways to create dynamic behavior in web applications?
Server-side scripting code and client-side scripting code
HTML and CSS
Static files and databases
XML and JSON
Which scripting code is executed on the server side?
JavaScript
PHP
HTML
CSS
Which scripting code is executed on the client side?
PHP
XML
JavaScript
Server-side scripting code
What is one of the advantages of server-side programming in terms of security?
Server-side code is visible to the client
Server-side code has access to the server's important and/or private data
Server-side code is slower to access
Server-side code can be modified by the client
How does server-side programming contribute to compatibility?
It requires users to update their browsers more frequently
It increases browser JavaScript compatibility issues
It avoids browser JavaScript compatibility issues
It has no effect on browser compatibility
What is an efficiency benefit of server-side programming?
Users have to run a script to view each page
Users have to send the entire data set from server to user's browser
It's slower for users
Users don't have to run a script to view each page
Which of the following is a power advantage of server-side programming?
There are more restrictions on what the server can do
It cannot open connections to other servers
It can write to files, open connections to other servers, connect to databases, etc.
It is limited to the capabilities of the client's browser
What happens when a PHP document is requested from a server?
The server sends the PHP document directly to the client.
The server processes the PHP document and sends an HTML page to the client.
The client processes the PHP document and sends it back to the server.
The PHP document is deleted from the server after the request.
What is the role of the server in the execution of a PHP file?
The server requests the PHP file from the client.
The server sends the PHP file to another server for processing.
The server executes the PHP file and creates a response HTML file.
The server stores the PHP file without executing it.
How many modes of operation does the PHP processor have?
One
Two
Three
Four
What happens in the copy mode of PHP processor operation?
PHP code is executed and the result is sent to the output file
PHP code is interpreted and the output from that code is sent to the output file
Plain HTML in the input file is copied to the output file
The output file is sent directly to the client without processing
What is required of the output of a PHP script in interpret mode?
Who sees the output produced by the PHP code?
The PHP processor
The server administrator
The client (i.e., the user)
The web developer
Which of the following is a characteristic of PHP?
Static typing
Typed variables
Associative arrays
Lack of libraries
PHP is known for having:
Limited pattern matching capabilities
No libraries available
Extensive libraries
Inflexible array structures
PHP code is contained between which tags?
and
and ?>
How can code be included in a PHP file?
include("table2.inc");
require("table2.inc");
insert("table2.inc");
append("table2.inc");
What happens when a file is included in PHP?
The PHP interpreter stops
The PHP interpreter reverts to copy mode
The PHP interpreter executes the file immediately
The PHP interpreter ignores the file
PHP code in an included file must also be enclosed in which tags?
and
and ?>
What is the correct way to start a PHP scripting block?
BEGIN PHP your PHP code END PHP
[PHP] your PHP code [/PHP]
What does a simple PHP program that outputs "Hello World" to the browser indicate?
The PHP installation is incorrect.
The PHP script is configured to send data to the server.
The PHP script can send output to the browser window.
The PHP script is an example of a complex program.
Which two basic output statements are used in PHP?
include and require
if and else
print and echo
for and while
What do the print and echo functions in PHP take as parameters?
Array parameters
String parameters
Integer parameters
Object parameters
Can you optionally surround strings in PHP with parentheses when using echo or print?
Yes, you can optionally use parentheses.
No, you cannot use parentheses at all.
Only with the echo function.
Only with the print function.
What is the purpose of the print and echo functions in PHP?
To define variables
To create functions
To send data to output
To perform arithmetic operations
PHP statements are terminated with what symbol?
A period (.)
A comma (,)
A semicolon (;)
A colon (:)
What is used to create compound statements in PHP?
Parentheses
Square brackets
Angle brackets
Curly braces
How can single line comments be started in PHP?
Multi-line comments in PHP begin with which symbols?
'//'
''
'/*' and end with '*/'
'#'
What symbol do all variable names in PHP begin with?
#
@
$
%
Are variable names in PHP case sensitive?
Yes
No
Only when used inside functions
Only when used outside functions
Are keywords and function names in PHP case sensitive?
Yes
No
Only keywords are case sensitive
Only function names are case sensitive
How are variables in PHP declared?
With a specific declare statement
Implicitly by assignment
By using the var keyword
With a specific type declaration
Do PHP variables require a type to be specified when they are declared?
Yes, always
No, never
Only for global variables
Only for local variables
How many scalar data types are mentioned in the document?
Two
Three
Four
Five
Which of the following is a function used to test the type of a variable in PHP?
test_type
get_type
is_type
is_string
What type of auto-conversion does PHP perform when a string is used with a plus (+) operator?
string to boolean
string to array
string to integer
string to object
Which of the following is an example of type-casting in PHP?
$age = "21"
$age = 21
$age = (int)"21"
$age = (string)21
PHP distinguishes between which two types of numeric types?
Integer and String
Floating point and Double
Integer and Floating point
Boolean and Integer
In PHP, an integer is usually equivalent to what data type in C?
char
int
long
short
What can double literals include in PHP?
Only decimal point
Only exponent
Decimal point or exponent
Neither decimal point nor exponent
String literals in programming are enclosed in what?
Parentheses
Single or double quotes
Brackets
Curly braces
What is true about double-quoted strings?
They cannot contain variables
They interpret escape sequences and variables are interpolated
They do not interpret escape sequences
They cannot span multiple lines
How is a literal $ sign represented in a double-quoted string?
Using a single quote
Preceding it with a backslash, \
By doubling the $ sign
It does not need to be escaped
Can double-quoted strings cover multiple lines in programming?
No, they are limited to a single line
Yes, but they cannot include end of line characters
Yes, and the included end of line characters are part of the string value
Yes, but only if concatenated with a plus sign
Which of the following is true about single-quoted strings?
They interpret escape sequences and variables are interpolated
They can span multiple lines without including end of line characters
They have neither escape sequence interpretation nor variable interpolation
A literal $ sign does not need to be escaped
In PHP, what is the output of the statement 'print "You are $age years old.\n";' if the variable $age is set to 16?
You are $age years old.
You are 16 years old.
You are .16. years old.
You are ${age} years old.
Which of the following statements correctly describes the use of single quotes and double quotes in PHP?
Variables inside single quotes are not expanded.
Variables inside double quotes are not expanded.
Both single and double quotes expand variables within strings.
Neither single nor double quotes can be used to enclose variable names within strings.
How is string concatenation indicated in PHP?
With a comma (,)
With a plus sign (+)
With a period (.)
With a semicolon (;)
How are characters accessed in a string in PHP?
Using square brackets []
Using parentheses ()
Using curly braces {}
Using angle brackets <>
What does the PHP function strlen do?
Removes whitespace from the end of a string
Compares two strings as strings
Gives the length of a string
Splits a string into an array
What does the PHP function strcmp do?
Splits a string into an array
Gives the length of a string
Removes whitespace from the end of a string
Compares two strings as strings
What does the PHP function chop do?
Compares two strings as strings
Splits a string into an array
Gives the length of a string
Removes whitespace from the end of a string
What will be the output of the PHP code shown in the example?
ThisisIS448
This IS448
Thisis448
This448is
How many values does the boolean type have?
One
Two
Three
Four
Which of the following values is NOT considered false in control expressions?
The integer value 0
The empty string
The literal string "0"
The literal string "1"
What does NULL count as in boolean type?
True
False
Undefined
Not applicable
Why should one be cautious with double calculations in boolean contexts?
They are always true
They are always false
They can be unpredictable
They rarely result in the exact value 0.0
When does implicit type conversion occur according to the context in which an expression appears?
When a string is used in a place where a boolean is required
When a numeric value is required and a string is used
When an array is used in a place where a string is required
When an object is used in a place where a numeric value is required
How is a string converted to an integer implicitly?
When the string contains only letters followed by digits
When the string contains only a sign followed by non-numeric characters
When the string contains only a sign followed by digits
When the string is a valid integer literal including a period or e or E
What is the correct way to force a type conversion to integer in the C style?
(double)$sum
(int)$sum
intval($sum)
settype($sum, "integer")
Which function can be used to determine the type of a variable?
gettype
settype
is_type
typeval
