Sei sulla pagina 1di 74

PHP and MySQL Web Development, Fifth Edition

Luke Welling and Laura Thomson

Chapter 1 Review Quiz

1. Which of the following is an example of a short-style PHP tag?

a. <?php echo '<p>Order processed.</p>'; ?>


b. <? echo '<p>Order processed.</p>'; ?>

c. <?php echo short_open_tag '<p>Order processed.</p>'; ?>

d. echo '<p>Order processed.</p>';

2 What is the purpose of the semicolon in PHP?

a. statement termination
b. concatenation

c. line continuation

d. subtraction

 How does the PHP engine process whitespace?

a. throws an error
b. throws a warning

c. prompts the user for input

d. ignores it

 Which of the following symbols represents a single-line comment in PHP?

a. //
b. /*

c. */

d. --

 PHP string interpolation requires:

a. braces
b. single quotation marks

c. parentheses
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. double quotation marks

6 Which of the following statements is false concerning PHP identifiers?

a. Identifiers cannot begin with a digit.


b. Identifiers can be of any length.

c. Identifiers are case insensitive.

d. Identifiers can have the same name as a function.


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 Which of the following PHP data types stores only true or false values?

a. Float
b. Array

c. Object

d. Boolean

8 Which of the following is a PHP function used to declare constants?

a. var
b. define
c. echo
d. phpinfo

9 Which of the following statements tests for equality between the PHP variables $a and $b?

a. $a = $b
b. $a == $b
c. $a -> $b
d. $a | $b

1 In PHP, which bitwise operation is signified by the pipe (|) character?

a. OR
b. XOR

c. AND

d. NOT
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 2 Review Quiz

1. To open a file in PHP, you use the _________ function.

a. fopen()
b. fputs()

c. open()

d. fp()

2 Which of the following is an alternative to the PHP file_put_contents() function?

a. fputs()
b. fopen()

c. fwrite()

d. fp()

3 In PHP, a while loop tests for the end of the file by using which function?

a. fputs()
b. fopen()

c. feof()

d. fgets()

4 The _________ function reads an arbitrary number of bytes from a file.

a. fread()
b. file_exists()

c. fgetc()

d. fgets()

5 Which of the following represents a reading lock of the flock() function?

a. LOCK_SH
b. LOCK_EX
c. LOCK_UN
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. LOCK_NB

6 Which of the following is NOT a problem of working with flat files in PHP?

a. Searching for a particular record is difficult


b. When a file becomes small, working with it can be very slow

c. Dealing with concurrent access can become problematic

d. All file processing is sequential


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 MySQL is an example of a(n):

a. LAMP
b. DBA

c. API

d. RDBMS

8 In PHP, writing data to a file requires how many steps?

a. 2
b. 3

c. 4

d. 1

9 Which of the following fopen() file modes denotes 'cautious write'?

a. w
b. x

c. b

d. w+

1 Disable PHP from opening files via fopen() and FTP by editing:

a. php.ini
b. fopen.ini

c. fopen.bin

d. php.bin
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 3 Review Quiz

1. What kind of PHP variable stores a single value?

a. array
b. scalar

c. dictionary

d. index

2 PHP indexes start at ________ by default.

a. 1
b. 0

c. null

d. -1

3 Which of the following expressions shows a correct PHP array definition?

a. $products = 'Tires':'Oil':'Spark Plugs';


b. $products = ['Tires', 'Oil', 'Spark Plugs'];
c. $products = ('Tires', 'Oil', 'Spark Plugs');
d. $products = {'Tires', 'Oil', 'Spark Plugs'};

4 The statement $products{0} accesses the ________ element in an array.

a. first
b. middle

c. last

d. overall

 The __________ construct can be used to split an array into a number of values.

a. while()
b. list()

c. foreach()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. each()

6 Which of the following PHP array operators signifies non-identity?

a. !==
b. !=

c. <>

d. `===
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 The PHP constant ____________ will sort an array as strings depending on the current
locale.

a. SORT_LOCALE
b. SORT_NATURAL

c. SORT_LOCALE_STRING

d. SORT_STRING

8 The three different PHP sorting functions are sort(), asort(), and:

a. ksort()
b. sortkr()

c. sorta()

d. sortr()

9 The _________ function modifies every element in an array the same way.

a. array_walk()
b. next()

c. reset()

d. prev()

1 An array containing other arrays is known as a(n) ___________ array.

a. multidimensional
b. scalar

c. sorted

d. non-indexed
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 4 Review Quiz

1. The trim() function removes whitespace:

a. from the end of a string


b. from the start and end of a string

c. from the start of a string

d. from the middle of a string

2 Which of the following is an alias for the chop() PHP function?

a. trim()
b. ltrim()

c. rtrim()

d. \0

3 Which of the following represents the HTML encoding of >?

a. &lt;
b. &gt;

c. &apos;

d. &amp;

4 Which PHP function takes a string as a parameter and replaces all the newlines in it with the
HTML <br /> tag?

a. str_replace()
b. n12br()

c. htmlspecialchars()

d. trim()

 Which of the following conversion specification type codes interprets as an integer and
prints as a character?
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

a. c
b. i

c. b

d. d
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6 Which of the following PHP expressions can get the domain name from a customer's email
address?

a. $email_array = explode('@', $email);


b. $email_array = join('@', $email);
c. $email_array = implode('@', $email);
d. $email_array = strtoupper('@', $email);

7 What is the result of the statement echo strlen("hello");?

a. 5
b. 1

c. False

d. True

8 The expression $test = substr_replace($test, 'X', -1); replaces:

a. The last character in $test


b. The second character in $test

c. The first character in $test

d. The entire $test string

9 What is the most common delimiter in PCRE regular expressions?

a. /
b. \

c. //

d. \\

1 Which of the following regex tokens anchors your match to the beginning of the subject
string?

a. /
b. $

c. ^
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. |
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 5 Review Quiz

1. Which of the following is a PHP statement that allows you to load a file into your PHP script?

a. #include
b. require()

c. main()

d. #require

2 Which of the following is a php.ini directive that points to a header file?

a. auto_append_file
b. require_prepend

c. auto_prepend_file

d. require_append

 What is the role of 'foo' in the PHP statement function('foo');?

a. code block
b. parameter

c. constant

d. variable

4 A PHP function's __________ lists its parameters and data types.

a. prototype
b. reference

c. member

d. variable

 Calls to PHP functions:

a. must appear in the footer of the page


b. must appear in the header of the page
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. are case-sensitive

d. are case-insensitive

 Which of the following statements is true concerning PHP functions?

a. PHP function names cannot begin with a digit.


b. PHP functions can have the same name as an existing function.

c. PHP functions must include parameters.

d. PHP function names can contain only letters, digits, and underscores.

 PHP variables that are declared inside a function are known as:

a. inside variables
b. local variables

c. outside variables

d. global variables

 In PHP, the normal way that function parameters are called is known as:

a. pass by data type


b. pass by reference

c. pass by value

d. pass by class

 The PHP keyword return:

a. pauses the execution of a function


b. continues the execution of a function

c. stops the execution of a function

d. restarts the execution of a function

1 A PHP function that calls itself is known as a _________ function.

a. local
b. recursive
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. global

d. return
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 6 Review Quiz

1. In object-oriented programming, __________ are properties or variables that relate to an


object.

a. operations
b. methods

c. functions

d. attributes

2 ________ are methods, actions, or functions that an object can perform to modify itself or
perform some external effect.

a. Attributes
b. Operations

c. Interfaces

d. Variables

3 The object-oriented principle of ____________ means that different classes can have
different behaviors for the same operation.

a. polymorphism
b. inheritance

c. class

d. variability

4 You create methods by declaring ________ within a PHP class definition.

a. classes
b. functions

c. variables

d. attributes

5 The PHP statement $a = new classname("First"); denotes a(n):


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

a. method
b. constructor

c. destructor

d. attribute
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6 What is the default PHP class access modifier?

a. protected
b. private

c. public

d. variable

7 Use the _________ keyword to specify that one class is to be a subclass of another.

a. extends
b. new

c. protected

d. private

8 Which of the following shows the correct use of the final PHP keyword?

1. function operation(final) {}
2. final function operation() {}
3. function final operation() {}
4. final function operation("final") {}

9 Which of the following programming languages does NOT support true multiple inheritance?

1. Python
2. C++

3. PHP

4. Smalltalk

1 In a PHP __________, you can group together functionality that may be reused in multiple
classes.

1. interface
2. trait

3. per-class constant

4. constructor
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 7 Review Quiz

1. In PHP, the keyword __________ triggers the exception-handling mechanism.

a. catch
b. throw

c. finally

d. try

2 In PHP you can have __________ catch block(s) associated with a single try block.

a. no
b. only one

c. more than one

d. only two

3 Which of the following is NOT a built-in method of the Exception PHP class?

a. getString()
b. getTrace()

c. getCode()

d. toString()

4. Which of the following shows the correct definition of a PHP exception?

a. Exception(new, $throw, $message, $code);


b. throw new Exception($message, $code);
c. new Exception($message, $code);
d. throw Exception(new, $message, $code);

5 In PHP, the ________ block always is executed after the try and catch blocks.

a. finally
b. exception

c. else
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. throw

6 A(n) __________ shows which functions were executing at the time the exception was
raised.

a. string
b. backtrace

c. trace

d. extension
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 Most of the public PHP exception methods are:

a. dynamic
b. final

c. idempotent

d. temporary

8 In PHP it's considered good coding practice to implement _______ try blocks in your code.

a. comprehensive
b. small

c. branching

d. large

9Which of the following is NOT a valid optional parameter of the PHP Exception class?

a. stack trace
b. error message

c. error code

d. previous exception

1 In creating your own subclass Exceptions, you can override the ________ built-in
function.

a. getCode()
b. toString()

c. getPrevious()

d. getFile()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 8 Review Quiz

1. What is the most commonly used type of database according to the book's authors?

1. flat file
2. document-based

3. relational

4. NoSQL

2 In a relational database table, each value must have the _____________ specified by its
column.

1. tuple
2. name

3. record

4. data type

3 A primary key can consist of ___________ column(s).

1. one or more
2. one

3. two

4. zero

4 What is the definition of a relational database schema?

1. Primary/foreign key relationship between tables


2. Complete set of table designs

3. Unique identifier for a table

4. Number of columns per table

5 Which of the following is NOT an example of an update anomaly?

1. modification
2. creation
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

3. insertion

4. deletion

6 Atomic column values mean that you store only _______ attribute(s) in each row.

1. 0
2. 1

3. more than one

4. array

7 Having many _________ values in your database wastes space and causes problems working
out totals.

1. binary
2. atomic

3. null

4. string

8 In a database-backed PHP application, the _________ opens a connection to the web


database.

1. end user
2. PHP code

3. web browser

4. PHP engine

9In relational database theory, a table is also known as a:

1. column
2. key

3. relation

4. attribute

1 A foreign key should have the same or comparable _________ as its related primary key.

1. string length
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

2. data type

3. name

4. column order
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 9 Review Quiz

1. What is phpMyAdmin?

a. MySQL installer
b. MySQL client libraries

c. MySQL administration desktop application

d. browser-based MySQL management tool

2 Which of the following is a valid MySQL connection command?

a. mysql -server dbserver -id joe -p


b. mysql -h dbserver -u joe -p

c. mysql -h dbserver -id joe -p

d. mysql dbserver -u joe -p

3 How do you create a new MySQL database?

a. new database dbname;


b. create database dbname;

c. deploy database dbname;

d. build database dbname;

4 You can use a(n) ____________ as an alternative to implementing MySQL user passwords.

a. passphrase
b. authentication plugin

c. PIN

d. biometric

5The ___________ MySQL statement allows a specified database user to grant his or her
own privileges to others.

a. WITH
b. WITH GRANT OPTION
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. GRANT

d. IDENTIFIED BY

6 Which of the following MySQL privileges allows users to remove databases, tables, or
views?

a. DROP
b. TRIGGER

c. DELETE

d. EXECUTE
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 Which of the following MySQL privileges allows users to run stored procedures and
functions?

a. EXECUTE
b. PROXY

c. INDEX

d. ROUTINE

8 LOCK TABLES is an example of a(n):

a. administrator stored procedure


b. user stored procedure

c. administrator privilege

d. user privilege

 The opposite of the MySQL GRANT statement is:

a. DENY
b. DROP

c. REVOKE

d. DISCONNECT

1 Which of the following commands do you use to specify which MySQL database you want
to use?

a. SWITCH
b. USE

c. USING

d. INCLUDE
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 10 Review Quiz

1. What does SQL stand for?

a. Standard Query Language


b. Structured Query Language

c. Structured Question Language

d. Standard Question Language

2 Which SQL clause follows INSERT INTO?

a. VALUES
b. SELECT

c. COLUMN

d. HAVING

3 The SELECT ___________ wildcard operator matches all the columns in the specified table or
tables.

a. *
b. ?

c. %

d. null

4 Which of the following WHERE clause operators tests whether two values are not equal?

a. IS NOT
b. !=
c. ><
d. IS NULL

5 Use the SQL _____________ keyword to perform regular expression matching.

a. LIKE
b. REGEXP
c. POSIX
d. IS NULL
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6 A(n) ___________ join represents the Cartesian product of two tables in a SQL database.

a. full
b. outer

c. double

d. inner
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 In the ANSI SQL standard, how many tables can be joined?

a. only 2
b. up to 4

c. up to 16

d. unlimited

8 What is represented by the C in the SQL statement SELECT C.Name FROM Customers AS C?

a. table alias
b. column alias

c. key alias

d. row alias

9 A SQL join with a WHERE clause is known as a:

a. inner join
b. equi-join

c. cross join

d. left join

1 What is the default sort order used by the SQL ORDER BY clause?

a. ascending
b. none

c. descending

d. pseudo-random
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 11 Review Quiz

1. What is the basic PHP library for connecting to MySQL?

a. mysqli
b. mysqlb

c. phpMyAdmin

d. mysqld

2. In PHP-MySQL connectivity, what is the purpose of the @ symbol?

a. error suppression
b. connection string

c. alternate credentials

d. HTTPS instead of HTTP transmission

3 max_connections is a ____________ parameter that determines the simultaneous MySQL


connection limit.

a. PHP
b. MySQL

c. Apache

d. SQL

4 MySQL ____________ can speed up query execution as well as protect against SQL
injection attacks.

a. query hints
b. stored procedures

c. triggers

d. prepared statements

5 The expression $result->free();:


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

a. sends a prepared statement to the MySQL server


b. disconnects from the MySQL database

c. stores the result set

d. returns the next row from the result set


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6 You can use the generic _______ functions if you want to use a database that doesn't already
have a PHP library.

a. SQL
b. XML

c. ODBC

d. LAMP

7 In database connection string terminology, DSN stands for:

a. data structure name


b. dynamic structure name

c. data source name

d. dynamic source name

8 What is the first step in querying a MySQL database from the web?

a. retrieve the results


b. check and filter data coming from the user

c. query the database

d. set up a connection to the appropriate database

9 Which of the following functions changes the default database?

a. mysqli_query()
b. mysqli_select_db()
c. mysqli_connect()
d. mysqli_switch()

1 Why is the query $query = "SELECT ISBN, Author, Title, Price FROM Book WHERE
$searchtype = '$searchterm'"; problematic?

a. too resource-intensive
b. missing an ORDER BY clause

c. susceptible to SQL injection


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. includes no exception handling


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 12 Review Quiz

1. What command is used to view all tables in the current MySQL database?

a. LIST TABLES;
b. SHOW TABLES;
c. SELECT TABLES;
d. VIEW TABLES;

2 Privilege-related MySQL tables have priv __________ the associated table name.

a. in the middle
b. instead of

c. after

d. before

3 The ___________ table determines which users can access which databases from which
hosts.

a. db
b. sys
c. priv
d. proxies

4 What is the first step in how MySQL uses grant tables to determine what a user is allowed to
do?

a. request verification
b. select verification

c. connection verification

d. multifactor authentication

5 What is the purpose of the flush privileges; MySQL command?

a. reset privileges to default


b. delete any assigned permissions

c. update privileges

d. request a user password reset


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6What is the most sensitive account password on a Unix- or Linux-based MySQL server?

a. admin
b. sa

c. root

d. sudo
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7Which MySQL function can perform one-way password encryption in a database?

a. password()
b. encrypt()
c. asymmetric()
d. flush()

8 Which of the following is NOT a MySQL command used to gather more information about a
given database?

a. GRANT
b. DESCRIBE
c. EXPLAIN
d. SHOW

9The ___________ MySQL statement is an alternative for the SHOW COLUMNS statement.

a. EXPLAIN
b. GRANT
c. SELECT
d. DESCRIBE

1What is the result of running the MySQL command EXPLAIN SELECT Customer,
Balance FROM Customers;?

a. reveals any user permissions


b. describes the result set

c. displays the query execution plan

d. reveals any system permissions


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 13 Review Quiz

1. What privilege is required for a MySQL database user to employ the LOAD DATA INFILE
statement?

a. FILE
b. ALTER

c. GRANT OPTION

d. INDEX

2What is the default storage engine used by MySQL?

a. MyISAM
b. MEMORY

c. InnoDB

d. MERGE

3 Which MySQL storage engine stores large amounts of data but with a small footprint?

a. MyISAM
b. ARCHIVE

c. InnoDB

d. MEMORY

 _____________ are mechanisms for ensuring database consistency.

a. atoms
b. MEMORY tables

c. MyISAM tables

d. transactions

5 What does "I" in the ACID transaction model signify?

a. InnoDB
b. INSERT
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. isolation

d. index

6 What is the purpose of the MySQL statement SET AUTOCOMMIT=0;?

a. turns autocommit on globally on the server


b. turns autocommit off in the current session

c. turns autocommit off globally on the server

d. turns autocommit on in the current session

7 A(n) __________ is a programatic function that is created and stored within MySQL.

a. stored procedure
b. trigger

c. function

d. index

8 What is the purpose of 'Total' in the MySQL statement CREATE PROCEDURE Total_Orders
(OUT Total FLOAT);?

a. parameter
b. function

c. stored procedure

d. trigger

 In MySQL, a deterministic function will, given the same parameter, always return:

a. an error
b. a different value

c. no value

d. the same value

1 In MySQL, the DECLARE statement appears in a ________ block.

a. START...END
b. BEGIN...END
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. TRY...CATCH
d. IF...ELSEIF
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 14 Review Quiz

1. Attacks that involve accessing or modifying your data as it travels over the network are known
as __________ attacks.

a. man-in-the-middle
b. traceroute

c. SSL

d. social engineering

2 A(n) ___________ attack occurs when somebody's actions make it difficult or impossible for
users to access a service.

a. DoS
b. MITM

c. SQL injection

d. SSL

3 Which of the following is an example of code injection?

a. CSS
b. XSS

c. DoS

d. MITM

4 What is the name of the default super user account on Microsoft Windows systems?

a. sa
b. administrator

c. root

d. superuser

5 What is the name of the default super user account on Linux systems?

a. root
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

b. sa

c. admin

d. administrator
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6 ______ occurs when a party involved in a transaction denies having taken part.

a. Non-repudiation
b. Man-in-the-middle

c. Repudiation

d. Cross-site scripting

7 ____________ attempt to find weaknesses in software and work their way past these to
achieve their goals.

a. Data spies
b. Crackers

c. Hardware thieves

d. Hackers

8 Which of the following is a good resource for learning more about the threats to your web
applications?

a. phpMyAdmin
b. MITM

c. XSS

d. OWASP

 The __________ process involves asking users to prove their identity.

a. authorization
b. indexing

c. authentication

d. accounting

1A ___________ involves somebody sending out junk e-mail with the target listed as the
sender.

a. reverse MITM
b. forward MITM
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. forward spam

d. reverse spam
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 15 Review Quiz

1. Web application developers must filter all input from:

a. the host web server


b. internal sources

c. external sources

d. the host operating system

2 The _______ extension has the added security advantage of allowing only a single query to
execute with certain methods.

a. httpd
b. mysqld
c. mysqli
d. myPHPadmin

3 The htmlspecialchars() function converts an input string into:

a. HTML tags
b. HTML entities

c. XML entities

d. XML tags

4 Which of the following is the HTML entity that represents the right angle bracket?

a. &quot;
b. &gt;

c. &lt;

d. &copy;

5 Which of the following terms refers to the reappearance of bugs previously cleared in your
code?

a. defenestation
b. regression
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. Q/A

d. prototyping

6Which of the following characters acts as an execution operator in UNIX?

a. backtick
b. parentheses

c. single quote

d. double quote

7 Consider keeping your _____________ file in source control and make sure to review its
contents frequently.

a. apache.conf
b. php.net
c. php.ini
d. httpd.ini

8 A(n) __________ is a screened subnet on which to place your public-facing web application
servers.

a. MITM
b. DMZ

c. DDoS

d. SSL

9 Which of the following is NOT a valid disaster recovery planning step?

a. maintain your documentation offsite


b. maintain offsite backups

c. run automated monitoring tools

d. run all core services under administrator privilege

1 Any file not intended to be directly user-accessible should be _____________ of the
website.

a. locked out
b. encrypted outside
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. in the document tree

d. outside
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 16 Review Quiz

1. The most common authentication method used in PHP web applications is ___________
authentication.

a. biometric
b. password

c. retinal

d. multi-factor

2 A one-way __________ mechanism can provide better password security with very little
extra effort.

a. compression
b. SSL

c. hashing

d. biometric

3 Which of the following is NOT a hashing algorithm?

a. MD5
b. Crypt

c. SSL

d. SHA1

4 In PHP 5.5, use the _________ function to apply a strong one-way hash to a string.

a. password_crypt()
b. password_hash()
c. crypt_blowfish()
d. pwhash()

5 Be certain to combine HTTP basic authentication with _____ to protect all parts of a web
transaction.

a. password hashing
b. auto_prepend_file
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. SSL

d. password salting
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

6 HTTP basic authentication relies on environment variables set by:

a. the MySQL storage engine


b. the PHP engine

c. the SSL certificate

d. the web server

7 The file _____________ is used on web servers to control access to files and subdirectories.

a. 401.html
b. .htaccess
c. php.ini
d. httpd.conf

8 Which of the following represents how to specify Basic authentication in the .htaccess file?

a. AuthType Basic
b. AuthName Basic
c. AuthBasicProvider true
d. ErrorDocument true

9 Basic authentication in Apache Web Server is controlled by:

a. mod_auth_digest
b. AuthName
c. AuthType
d. mod_auth_basic

1 What is the default password hashing algorithm in PHP 5.5?

a. MD5
b. Blowfish

c. SHA1

d. SHA2
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 17 Review Quiz

1. Which php.ini directive controls whether HTTP file uploads are allowed?

a. upload_max_filesize
b. upload_tmp_dir
c. file_uploads
d. post_max_size

2 Which php.ini directive defines how often the session upload progress information should
be updated?

a. session.upload_progress.min_freq
b. session.upload_progress.enabled
c. session.upload_progress.freq
d. session.upload_progress.prefix

3 You can implement the PHP __________ function to mitigate the risk of users "directory
surfing" your web server.

a. feof()
b. basename()
c. file()
d. ftell()

4 The PHP rmdir() function is used to:

a. delete directories
b. rename directives

c. delete directives

d. rename directories

5 Which of the following PHP functions is NOT supported on Windows-based web servers?

a. mkdir()
b. file()
c. fileowner()
d. rmdir()

6 Which PHP function returns the timestamp of the time the file was last modified?

a. filemtime()
b. fileatime()
c. filetype()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. fileperms()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7Which of the following is a PHP function that changes the permissions on a file?

a. chperm()
b. chmod()
c. chgrp()
d. chown()

8 Which of the following is a PHP function that can be used to delete files?

a. unlink()
b. rmdir()
c. delete()
d. rm()

9 What is the result of the command exec("ls -la"); when run on a UNIX system?

a. returns a list of recently deleted directories


b. returns a directory listing from the host server

c. runs an external command in the user's browser

d. runs a stored procedure on the web server

1 The PHP function _________ can stop users from maliciously (or otherwise) executing OS
commands on your web server.

a. escapeshellcmd()
b. exec()
c. passthru()
d. proc_close()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 18 Review Quiz

1. Most Internet standards and protocols are documented in:

a. TXTs
b. RFCs

c. POP3s

d. RPCs

2 Which of the following protocols can be used to send email?

a. SMTP
b. POP3

c. TLS

d. IMAP4

3 The _________ library allows you to log into a website and mimic a user's progress through
a few pages.

a. cURL
b. fopen

c. RFC

d. FTP

4 In the URL construction http://nobody:secret@example.com:80/


script.php?variable=value#anchor. which part represents the query?

a. variable=value
b. /script.php

c. anchor

d. example.com

5 Using PHP, we can use ___________ and FTP file functions to connect to and transfer files.

a. fopen()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

b. feof()
c. file()
d. fileatime()

6 It's good practice to provide a(n) ____________ when connecting to anonymous FTP sites.

a. password
b. email address

c. IP address

d. hostname

7 The statement ftp_pasv($conn, true); ensures that:

a. anonymous login will be disabled


b. anonymous login will be enabled

c. all data connections will be initiated by the remote FTP server instead of by the client

d. all data connections will be initiated by the client rather than by the remote FTP server

8 The two modes for an FTP transfer are ASCII and:

a. binary
b. octal

c. decimal

d. hexadecimal

9 The PHP function ftp_fget() differs from ftp_get() in that the former:

a. does not require the local file to be open


b. resets file permissions

c. requires the local file to be open

d. does not reset file permissions

1 What is the default execution time for PHP scripts?

a. 60 seconds
b. 90 seconds
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. 30 seconds

d. 120 seconds
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 19 Review Quiz

1. Which of the following is the php.ini setting that controls the default time zone?

a. date.timezone
b. date.time
c. timezone.date
d. strtotime.timezone

2 The function call echo date('jS F Y'); produces a date in the format:

a. 17th February 2016


b. 17 Feb 2016
c. Feb 17 2016
d. February 17th 2016

3 Which of the following date() format codes identifies the time zone?

a. e
b. d

c. i

d. I

 Use the _________ PHP function to convert a date and time to a UNIX timestamp.

a. mktime()
b. strftime()
c. microtime()
d. gmmktime()

5 The date January 1, 1970, GMT represents the:

a. Windows epoch
b. Windows time zone

c. UNIX epoch

d. UNIX time zone

6 Which of the following PHP functions is useful to check whether a date is valid?

a. date_sub()
b. date_modify()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. date_parse_from_format()
d. checkdate()
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 Which of the following strftime() formatting codes denotes the month?

a. %X
b. %M

c. %S

d. %B

8 Dates and times in _________ are handled in ISO 8601 format.

a. MySQL
b. PHP

c. Apache

d. Bash

9 Which of the following DATE_FORMAT() format codes denotes the day of the year, numeric?

a. %j
b. %p

c. %Y

d. %D

1 The microtime() function measures time in:

a. milliseconds
b. microseconds

c. nanoseconds

d. seconds
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 20 Review Quiz

1. In order to create localized software, you must first ____________ it.

a. internationalize
b. modify

c. internalize

d. translate

2 Traditional Chinese is an example of a(n) ___________ language.

a. multi-byte
b. single-byte

c. internationalized

d. localized

3 The PHP function ______ provides an API wrapper to the GNU gettext package.

a. bin2hex()
b. chr()
c. gettext()
d. fprintf()

4 en_US and de_DE are examples of:

a. locale identifiers
b. string identifiers

c. translation identifiers

d. externalization identifiers

5. In a single-byte language, ________ bits are necessary to represent a character.

a. 256
b. 1

c. 8
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. 16

6 Which of the following is a character set-related security issue with PHP and MySQL?

a. exclusive use of multi-byte languages


b. encoding mismatch

c. exclusive use of single-byte languages

d. PHP version
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 In order to use gettext() in PHP, you must first install:

a. GNU bash
b. GNU gettext

c. MySQL

d. Apache Web Server

8 When configuring PHP for compiling on Linux or macOS, use the _________ configuration
flag.

a. --disable-short-tags
b. --enable-libgcc
c. --with-gettext
d. --with-libdir

9 Verify GCC gettext support on your PHP web server by calling the _________ function.

a. phpversion()
b. phpcredits()
c. phpinfo()
d. php_check_syntax()

1 Which extension is used for translation files?

a. .cfg
b. .po

c. .conf

d. .bin
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 21 Review Quiz

1. The ________ image library is included but not enabled by default in PHP.

a. Intervention Image
b. GD2

c. ImageMagick

d. Zebra_Image

2Which of the following image formats does NOT support transparency?

a. JPEG
b. PNG

c. GIF

d. SVG

3 What is the first step to creating an image in PHP?

a. drawing shapes or printing text


b. creating a canvas image

c. outputting the graphic

d. cleaning up resources

4 What action is performed by the PHP statement $im = imagecreatetruecolor($width,


$height);?

a. drawing shapes or printing text


b. creating a canvas image

c. outputing the graphic

d. cleaning up resources

5 What color format is required by the imagecolorallocate() PHP function?

a. CMYK
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

b. PMS

c. RGB

d. SVG

6 In PHP, image coordinates start from the __________ corner.

a. bottom left
b. top right

c. top left

d. bottom right

7 Which PHP image management function returns the resources you've been using on the
server?

a. imagestring()
b. imagedestroy()
c. imagepng()
d. imageline()

8 The PHP function imagecreatefrompng() creates a PNG image:

a. only on the server's file system


b. on the user's file system

c. only in memory

d. in memory and on the server's file system

9 Under Windows, PNG images are supported as long as you have the __________ extension
registered.

a. libpng
b. php.ini

c. php_gd2.dll

d. zlib

1 Which of the following image formats uses lossy compression?

a. SVG
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

b. PNG

c. JPEG

d. GIF
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 22 Review Quiz

1. Sessions in PHP are driven by:

a. stateful packet inspection


b. a unique session ID

c. URIs

d. stateless HTTP

2 An HTTP cookie is a small piece of information that PHP scripts store most often:

a. on a network load balancer


b. on a client-side machine

c. on the MySQL server

d. on the PHP server

3. Which PHP function can be used to delete an HTTP cookie?

a. delete_cookie()
b. rmcookie()
c. setcookie()
d. remove_cookie()

4 Which php.ini directive should be set to instruct PHP to store session IDs in URLs?

a. session.gc_maxlifetime
b. session.cache_expire
c. session.use_trans_sid
d. session.cookie_domain

5 The second step in using PHP sessions is:

a. using session variables


b. registering session variables

c. starting a session

d. deregistering variables

6 Which of the following php.ini directives defines where session data is stored?
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

a. session.save_handler
b. session.use_cookies
c. session.cookie_domain
d. session.cookie_secure
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 HTTP cookie data is stored as:

a. hexadecimal numbers
b. Unicode text

c. key/value pairs

d. binary numbers

8 Which of the following is NOT an element in a session control cookie array?

a. path
b. unsecure
c. domain
d. lifetime

9 In PHP, session IDs are stored in which constant?

a. TRANS_ID
b. SID
c. SESSION_ID
d. TRANS_SESSION_ID

1 Which action is performed by the PHP statement $_SESSION['myvar'] = 5;?

a. retrieving cookie data


b. setting a cookie

c. destroying a session variable

d. creating a session variable


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 23 Review Quiz

1. What does the "X" in "AJAX" stand for?

a. XHTML
b. XAML

c. XPath

d. XML

2 What consequence does the "A" in "AJAX" have?

a. fewer database fetches


b. increased page security

c. fewer page refreshes

d. reduced number of authentications

3 What is the alias symbol for the jQuery namespace?

a. /
b. $

c. ?

d. #

4 The statement var nameElements = $('.name'); is an example of ________ syntax.

a. id selector
b. class selector

c. name selector

d. token selector

5 The jQuery __________ event fires when all the resources for a given HTML document have
been properly loaded.

a. proxy
b. ready
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

c. trigger
d. bind

6 Which of the following jQuery events is triggered when a form element receives focus?

a. focusout
b. focus
c. hover
d. focusin
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

7 Fundamentally, all AJAX methods are simplified versions of the ___________ API method.

a. $.get()
b. $.post()
c. $.getJSON()
d. $.ajax()

8 You integrate the jQuery library into your web application through the ________ tag.

a. src
b. script
c. head
d. a

9 The jQuery.noConflict() method is helpful to avoid conflicts with other libraries that use
the _________ symbol.

a. #
b. $

c. &

d. %

1 The statement var nameElements = $('#first_name #last_name'); selects elements


with a particular ___________ attribute.

a. class
b. id

c. tag

d. global
PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

Chapter 24 Review Quiz

1. The PHP function eval() evaluates a _______ as PHP code.

a. string
b. integer

c. float

d. Boolean

2 What does the PHP construct exit return?

a. 0
b. true

c. nothing

d. 1

3 Which term refers to the process of turning anything you can store in a PHP variable into a
bytestream?

a. AJAX
b. array

c. concatenation

d. serialization

4 What PHP function allows you to easily see what function sets are available?

a. get_loaded_extensions()
b. extension_loaded()
c. phpinfo()
d. dl()

5 The PHP function get_current_user() identifies the user:

a. who owns the script


b. who deleted the script

c. who last run the script


PHP and MySQL Web Development, Fifth Edition
Luke Welling and Laura Thomson

d. who last modified the script

6 The ini_get() function allows you to change __________ directives.

a. php.ini
b. phpinfo

c. my.ini

d. httpd.conf

7 Which of the following PHP functions is a synonym of highlight_file()?

a. show_source()
b. pack()
c. highlight_script()
d. highlight_string()

8 What is missing in the statement php -r 'for($i=1; $i<10; $i++) echo $i;'?

a. nothing; the code runs as expected


b. PHP tags

c. curly braces

d. XHTML tags

9 What is the most common use case for the PHP eval() function?

a. AJAX applications
b. templating systems

c. jQuery widgets

d. JSON object data

1 Which of the following is an alias of the PHP die() function?

a. unpack()
b. usleep()
c. exit()
d. __halt_compiler()

Potrebbero piacerti anche