Finals Flashcards

1
Q

Type casting, changes the data type of a variable from one data type to another. True or False?

A

False

Chapter 1 (page 59)

Casting or Type casting creates an equivalent value in a specific data type for a given value.

Even though PHP automatically assigns the data type of a variable, sometimes you want to ensure that a variable is of the data type or type casting. Type casting or casting copies the value contained in a variable of one data type into a variable of another data type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When you pass a variable name to the echo statement, you must enclose the variable name in a double quotation marks. True or false?

A

False

Chapter 1 (page 14)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

All Web pages containing PHP code must have an extension on .php. True or false?

A

True

Chapter 1 (page 2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The___ function is used to create a constant.

a) define ()
b) create ()
c) describe ()

A

define ()

Chapter 1 (page28)

A constant contains information that does not
change during the course of program execution

Constant names do not begin with a dollar sign

Constant names use all uppercase letters

Use the define() function to create a constant
define (“
CONSTANT_NAME “, value);

The value you pass to the define() function
can be a text string, number, or Boolean value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A(n) ___ is an element’s numeric position within an array.

a) location
b) index
c) indicator

A

index

Chapter 1 (page 34)

By default, indexes begin with the number
zero (0)

An element is referenced by enclosing its index in
brackets at the end of the array name:
$Provinces[1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Data types that can be assigned only a single value are called ___ types.

a) mono
b) primitive
c) individual

A

primitive

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The ___ function tests whether a variable contains a numeric data type.

a) is_digit ()
b) is_number ()
c) is_numeric ()

A

is_numeric ()

Chapter 1 (page 60)

is_numeric () function tests whether a variable contains a numeric data type, whereas the is_string () function test whether a variable contains a string data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

___ are symbols such as the (+) symbol that are used in expressions to manipulate operands.

a) Operators
b) Expressions
c) Literals

A

Operators

Chapter 1 (page 40)

Operators are symbols such as the addition operator (+) and multiplication operator (*), which are used in expressions to manipulate operands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

One way to ensure that a variable is of the correct data type is through type ___.

a) identifying
b) casting
c) naming

A

casting

Chapter 1 (page 59)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The ___ operator uses the % symbol to find the remainder of integer division.

a) modulus
b) division
c) arithmetic

A

modulus

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
1 - Standard PHP script delimiters
2 - The  element
3 - Short PHP script delimiters
4 - ASP=style script delimiters
Which of the above are NOT valid in PHP 7?

a) 3 & 4
b) 2 & 4
c) 2 & 3
d) They are all valid in PHP 7

A

2 & 4
The element
ASP-style script delimiters

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following is NOT a valid PHP comment block?

a)
b) /* Comment */
c) // Comment
d) # Comment

A

a)

this is an HTML comment, not PHP

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following is PHP?

a) Strongly typed
b) Loosely/weakly typed
c) Neither
d) Both

A

Loosely/weakly typed - we don’t declare data types, just use identifiers.

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Territories = array(“Nunavut”, “Northwest Territories”, “Yukon Territory”);

What is the index of the element “Yukon Territory”?

a) 0
b) 1
c) 2
d) 3

A

2

Array indices starts at 0.

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

$var = 9;
echo $var %2

What does the above expression resolve to /print?

a) 1
b) 2
c) 4
d) 9

A

1
Modulus will return the remainder

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

$var = 9;
echo $var++;

What does the above expression resolve to /print? (Tricky)

a) 9
b) 10
c) 1
d) This will throw an error

A

a) 9
$var increments after it prints

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

$varA = 9;
$varB = 3;
echo ($varA === $varB || $varA > $varB);

What does the above expression resolve to /print?

a) 0/False
b) 1/True
c) 3
d) This will throw an error

A

b) 1/True

|| Returns TRUE if either the left operand or right operand returns a value of TRUE, otherwise (neither operand returns a value of TRUE), it returns a value of FALSE

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

$varA = 9;
$varB = 3;
echo !($varA === $varB && $varA > $varB);

What does the above expression resolve to /print?

a) 0/False
b) 1/True
c) 3
d) This will throw an error

A

b) 1/True

&& or AND
Returns TRUE if both the left operand and right operand return a value of TRUE; otherwise it returns a value of FALSE.

Chapter 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Variable scope refers to the location that a declared variable can be used. True or False?

A

True

Chapter 2

Variable scope is where in your program a
declared variable can be used

A variable’s scope can be either global or local

A global variable is one that is declared outside
a function and is available to all parts of your
program

A local variable is declared inside a function
and is only available within the function in which
it is declared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
What will the following code print?  (Note the comment block)
$GlobalVariable = "Global variable";
function scopeExample () {
// global $GlobalVariable;
echo"<p>GlobalVariable </p>";
}
scopeExample();

a) “Global Variable”
b) Error

A

Error

“Undefined Variable

Chapter 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
What will the following code print?
$GlobalVariable = 3;
function scopeExample() {
   $GlobalVariable = 5;
   global $GlobalVariable;
   $GlobalVariable--;
   echo $GlobalVariable;
}
scopeExample();

a) 3
b) 5
c) 2
d) 4

A

c) 2

The most recent declaration overwrites the variable

Chapter 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q
$light="pink";
$speed=0;
switch($light ){
case"red":speed = 0;
case"yellow":$speed = 10;
break;
case"green":$speed= 30;
break;
default:$speed= -1;
break;
}
echo $speed;

What will the following code print?

a) 0
b) 10
c) 30
d) -1

A

d) -1

Speed changes on the default case which hits because none of the other cases do

Chapter 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
$numbers =array(10,20,30,40,50);
for ($i=0; $i <=3; $i++) {
   $numbers[$i] /= 10;
}
echo $numbers[4];

What will the following code print?

a) 20
b) 25
c) 40
d) 50

A

d) 50

$numbers[4] is 50 which is never modified

Chapter 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

You will not receive an error if you attempt to use a foreach statement with any variable types other than arrays. True or False?

A

False

Chapter 2

foreach Statements
Used to iterate or loop through the elements in
an array

Do not require a counter; instead, you specify an
array expression within a set of parentheses
following the foreach keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Functions are place within parentheses that follow a parameter name. True or False?

A

False

Chapter 2

The syntax for defining a function is

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

A ___ is a variable that increments or decrements with each iteration of a loop statement

a) counter
b) repetitor
c) incrementer/decrementer
d) iterator

A

a) counter

Chapter 2 (page 96)

A counter is a variable that increments or decrements with each iteration of a loop statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which of the following terms is not associated with the switch statement?

a) switch title
b) executable statement
c) break keyword
d) case label

A

a) switch title

Chapter 2 (page 92)
A switch statement consists of the following components:  the keyword switch, an expression, an opening brace, one or more case statements, a default label , and a closing brace.  A case statement consists of a case label, the executable statements, and the keyword break.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

With many programming languages, global variables are automatically available to all parts of your program, including ___.

a) definitions
b) functions
c) statements
d) declarations

A

functions

Chapter 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What will be returned if you use a local variable outside the function in which it is declared?

a) function
b) nothing
c) error message
d) value

A

c) error message

Chapter 2 (page 82)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

When you declare a global variable with the global keyword, you do not need to assign the variable a(n) ___.

a) name
b) definition
c) value
d) function

A

c) value

Chapter 2 (page 82)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

If you do not include code that changes the value used the by the condition expression, your program will be caught in a ___ loop.

a) infinite
b) constant
c) continuous
d) continuing

A

a) infinite

Chapter 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Regular expressions are patters that are used for matching and manipulating strings according to specified rules. True or False?

A

True

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

The strtok() function breaks a program into functions. True or False?

A

False

Chapter 3

strtok() function is used to break a string into smaller strings, called tokens

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

The opposite of the explode() function is the implode() function. True or False?

A

True

Chapter 3

The explode() function splits a string into an indexed array at a specified separator

The implode() function combines an array’s elements into a single string, separated by specified characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

The similar_text () function returns the number ___ two strings have in common.

a) characters
b) sounds
c) numbers
d) words

A

a) characters

Chapter 3 (page 158)

The similar_text() function are used to determine the similarity between two strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

The escape sequence to insert a carriage return is ___.

a)
b) \t
c) \r
d) \cr

A

\r

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

The ___ metacharacter is used to allow a string to contain an alternate set of substrings.

a) (!)
b) ()
c) (|)
d) (/)

A

(|)

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

The escape sequence \ inserts a(n) ___.

a) backslash
b) web ink
c) directory
d) comment

A

backslash

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

The most commonly used string counting function is the ___ function, which returns the total number of characters in a string.

a) str_count ()
b) total ()
c) strlen ()
d strpos ()

A

strlen ()

Chapter 3

The most commonly used string counting function is the strlen () function, which returns the total number of characters in a string.
Escape sequences, such as \n, are counted as one character.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

The ___ metacharacter is used to specify a range of values in a character class.

a) (‘)
b) (+)
c) (-)
d) (@)

A

(@)

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

A structure in which variables are placed within curly braces inside of a string is called a ___.

a) complex string syntax
b) function
c) method
d) simple string syntax

A

complex string syntax

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q
$str = "hello world";
$str = trim($str);
$str = substr($str, 6);
$str = ucfirst($str);
echo $str;

What will the following code print?

a) hello
b) Hello
c) world
d) World

A

World

trrm() cuts the beginning and end spaces off (nothing)

substr() returns the substring starting at character 6 (w)

ucfirst() capitalizes the first letter of the string

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

preg_match(“/[A-Z]/”, $Input) === 1
What is the above function call matching for against $Input? AKA, what will be indicated if this statement resolves to true?

a) At least one letter
b) At least one uppercase letter
c) No letter
d) No uppercase letters

A

At least one uppercase letter
[A-Z] indicates upper case

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

preg_match(“/^[A-za-z\d]”, $input) === 1

What is the above function call matching for against $Input? AKA, what will be indicated if this statement resolves to true?

a) At least one letter
b) At least one alphanumeric character
c) No alphanumeric characters
d) At least one non-alphanumeric character

A

At least one non-alphanumeric character

[^] means to exclude the pattern and so we are excluding upper case ([A-Z], lower case ([a-z]) and digits (\d)

Chapter 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

When the form data is submitted using the get method, the form data is appended to the URL specified in the form’s method attribute. True or False?

A

False

Chapter 4

The “get” method appends the form data to the URL specified in the form’s action attribute.
When the “get” method is used, PHP creates a populates a $_GET array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

From, CC, BCC and Date headers are examples of additional headers. True or False?

A

True

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

When you click a form’s submit button, each field on the form is sent to the Web server as a ___ pair.

a) true/false
b) variable/value
c) name/value
d) yes/ no

A

name/value

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

We can use ___ autoglobal array to refer to the global version of a variable from inside a function.

a) $GLOBALS
b) $_GLOBALS
c) $_GLOBAL
d) $GLOBAL

A

$GLOBALS

Chapter 4 (page 190)

You must use the global keyword to reference a global variable within the scope of a function. You can also use the $GLOBALS autoglobal array to refer to the global version of a variable from inside a function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

When you use the ___ method to submit form data to the processing script, the form data is appended to the URL specified by the action attribute.

a) get
b) submit
c) post
d) request

A

get

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

The ___ function can be used to ensure that a number has the appropriate number of decimal places.

a) set_decimal()
b) decimal_round()
c) round()
d) round_dec()

A

round()

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Which of the following is NOT a required argument of the mail() function?

a) recipient(s)
b) message
c) from
d) subject

A

from

Chapter 4 (page 206)

An e-mail message is sent using the mail() function. The basic syntax for this function is :
mail(recipient(s), subject, message);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

Autoglobals or superglobals are predefined ___.

a) constants
b) arrays
c) functions
d) variables

A

arrays

Chapter 4 (page189)

Autoglobals are associative arrays, which are arrays whose elements are referred to with an alphanumeric key instead of an index number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

The script in the dynamic data section of the Web page template will check the value of the ___ array to determine which page to display, assuming the name being passed is ‘page’.

a) $_GET[‘page’]
b) $_POST[‘page’]
c) $_PAGE[‘page’]
d) $SUBMIT[‘page’]

A

$_GET[‘page’]

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

Name:

How do we get the email value into “$email” after form submission?

a) $email = $_REQUEST[“email”];
b) $email = $_SERVER[“email”];
c) $email = $_POST[“email’”};
d) $email = $_GET[“email”];

A

$email = $_REQUEST[“email”];

$email = $_POST[“email’”};

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

The round() function can be used to ensure that number have the appropriate number of digits after the decimal point, if any. True or False?

A

True

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

You must use the global keyword to reference global variable within the scope function. True or False?

A

True

Chapter 4 (page 190)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

With complex escaping from XHTML, you can close one PHP block, insert some XHTML elements, and then open another PHP block to continue the script. True or False?

A

False

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

The value of the ___ attribute identifies the program on the Web server that will process the form data when the form is submitted.

a) name
b) action
c) id
d) method

A

action

Chapter 4 (page 192)
The value of the action attribute identifies the program on the Web server that will process the form data when the form is submitted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

The additional headers argument needs to be formatted to conform to the syntax of headers in the ___ documentation.

a) Internet Mail Format
b) Internet Email Format
c) Email Message Format
d) Internet Message Format

A

Internet Message Format

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

The ___ autoglobal can be used to access the result from form data sent with both the get and post methods.

a) $_SUBMIT
b) $_FILES
c) $_FORMS
d) $_REQUEST

A

$_REQUEST

Chapter 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

The ___ function can be used to determine if a variable contains values.

a) null
b) empty()
c) blank()
d) in_null()

A

empty()

Chapter 4 (page 199)
The empty() function can be used to determine if a variable contains values.  The empty() function returns a value of FALSE if the variable being checked has a nonempty and nonzero value, an a value of TRU if the variable has an empty or zero value.
62
Q

The ___ function displays the elements of the $_ENV array and their values.

a) systeminfo()
b) env_info()
c) php_info()
d) phpinfo()

A

phpinfo()

Chapter 4 (page 190)
The phpinfo() function displays the elements of the $_ENV array.

$_ENV autoglobal contains the environmental variable set for the operating system on the machine that hosts the Web server. Environment variables are variables that programs use to interact with the system.

63
Q

The ___ function is used to reverse the changes made by magic quotes or the addslashes() function.

a) removeslashes()
b) addslashes()
c) delshashes()
d) stripslashes()

A

stripslashes()

Chapter 4 (page 197)

The stripslashes() function removes any slashes that occur before a single quote (‘), double quote (“) or NUL character. All other slashes are ignored.

64
Q

Some operating systems always list two directory entries named “.” and “..”, which refer to the current directory and the directory that contains the current directory.
True or False

A

True

Chapter 5

65
Q

The a+ mode argument opens the specified file for reading only and places the file pointer at the beginning of the file.
True or False?

A

False

Chapter 5 (page 268)

a+ Opens the specified file for reading and writing and places the file pointer at the end of the file; attempts to create the file if it doesn’t exist

66
Q

An additional form attribute, enctype, with a value of “multipart/form-data” must be used to upload files.
True or False?

A

True

Chapter 5

An enctype attribute in the opening form tag must have a value of “multipart/form-data”, which instructs the browser to post multiple sections - one for regular form data and one for the file contents.

67
Q

What function returns a value of true when the file pointer reaches the end of the file?

a) eof()
b) feof()
c) file_end()
d) end_of_file()

A

feof()

Chapter 5 (page 275)
The feof() function accepts a single argument containing the handle for the open file.
68
Q

What function is used to delete files?

a) unlink()
b) del_file()
c) delete_file()
d) delete()

A

unlink()

Chapter 5

You use the unlink() function to delete files and the rmdir() function to delete directories. You pass the name of a file to the unlink() function and the name of a directory to the rmdir() function.

69
Q

Every time you use the ___ function, the file pointer moves to the next character in the file.

a) fopen()
b) fclose()
c) fgetc()
d) fileread()

A

fgetc()

Chapter 5 (page 275)
The fgetc() function does not advance the file pointer, while the fread() function advances the file pointer to the next available character.  Each time you call the fgetc() function, the file pointer moves to the next character in the file.
70
Q

The ___ function only works when there are “.” and “..” are the only two entries present in a directory.

a) remove_directory()
b) del_directory()
c) delete_directory()
d) rmdir()

A

rmdir()

Chapter 5 (page 282)
You use rmdir() function to delete directories.
The rmdir() function takes a little more developmental effort because it does not work unless a directory is empty.
71
Q

The operational constant of the flock() function that opens the file with an exclusive lock for writing is the ___.

a) LOCK_UN
b) LOCK_NB
c) LOCK_EX
d) LOCK_SH

A

LOCK_EX

Chapter 5 (page 272)
The LOCK_EX constant creates an exclusive lock to write data to the file.  An exclusive lock prevents other users from accessing the file until you are finished with it.
72
Q

On a Macintosh platform, you append the ___ carriage return escape sequence to the end of the line.

a) \rn
b) \n
c) \nr
d) \r

A

\r

Chapter 5 (page 234)
Different operating systems use different escape sequences to identify the end of a line.  UNIX/Linux platforms use the \n carriage return escape sequence, Macintosh applications usually use the \r line feed escape sequence and Windows operating systems use the \n carriage return escape sequence followed by the \r line feed escape sequence.
73
Q

When a form is posted, information from the uploaded file is stored in the ___autoglobal array.

a) UPLOAD_FILES()
b) FILE_UPLOAD()
c) $_UPLOAD()
d) $_FILES()

A

$_FILES()

Chapter 5 (page 248)

When the form is posted, information for the uploaded file is stored in the $_FILES[] autoglobal array.

74
Q

What is the value of $currentDir?

a) home
b) pictures
c) pictures/home
d) home/pictures

A

home

We never chdir(‘pictures”)

Chapter 5

75
Q

An additional form attribute, enctype, with a value of “multipart/form-data” must be used to upload files. True or False?

A

True

Chapter 5

76
Q

What will the following script print?

a) “test.txt”
b) “r”
c) “Hello”
d) Nothing/Will not print

A

Nothing/Will not print

Chapter 5

77
Q

The array_search() function determines whether a given value exists in an array and returns the negative value of the first matching element is it exists or false if it does not exist. True or False?

A

False

Chapter 6

78
Q

You can use the unset() function to remove array elements and other variables. True or False

A

True

Chapter 6

79
Q

You refer to the values in a multidimensional indexed array by including two sets of brackets, one which refers to the row and one which refers to the column. True or False?

A

True

Chapter 6

80
Q

You can create ___ that consist of multiple indexes or keys.

a) multidimensional arrays
b) indexed arrays
c) key arrays
d) two-dimensional arrays

A

multidimensional arrays

Chapter 6

81
Q

The ___ argument of the array_splice() function indicates the name of the array you want to modify.

a) array_mod
b) array_value
c) array_name
d) array_function

A

array_name

Chapter 6 (page 310)

82
Q

The ___ function lets you add or remove elements anywhere else in the array.

a) array_value()
b) array_splice()
c) array_split()
d) array_add()

A

array_splice()

Chapter 6 (page 310)

83
Q

The __ function removes duplicate elements from an array

a) array_dup()
b) array_unique()
c) array_values()
d) array()

A

array_unique

Chapter 6 (page 314)

84
Q

The symbol ___ appends one array to another.

a) ==
b) &&
c) +
d) ‘

A

+

Chapter 6 (page 343)
To append one array to another, you use the addition (+) or additive compound assignment operator (+=).
85
Q
To perform a reverse sort on an associative array by key and maintain the existing keys, use the \_\_\_ function.
a)  uk_sort()
b)  krsort()
c)  sort()
d  ksort()
A

krsort()

Chapter 6 (page 337)

86
Q

The ___ function determines whether a given value exists in an array.

a) array_search()
b) find_array()
c) array_values()
d) in_array()

A

array_search()

Chapter 6

87
Q

The array_search() function determines whether a given value exists in an array and returns the negative value of the first matching element if it exists or false if it does not exist. True or False?

A

False

Chapter 6 (page 328)

The array_search() function determines whether a given value exists in an array, then returns the “index or key” of the first matching element if it exist or FALSE if it does not.

88
Q

You can use the unset() function to remove array elements and other variables. True or False?

A

True

Chapter 6 (page 313)

The unset() function remove array elements and other variables. You pass the unset() function the array name with the index number of the element you want to remove in brackets.
Example:
unset ($HospitalDepts[1], $HospitalDepts[2]);

89
Q

You refer to the values in a multidimensional indexed array by including two sets of brackets, one which refers to the row and one which refers to the column. True or False?

A

True

Chapter 6 (page 352)

Multidimensional Indexed Array syntax:

array_name[index], [index]

90
Q

You can create ___ that consist of multiple indexes or keys.

a) multidimensional array
b) indexed arrays
c) key arrays
d) two-dimensional arrays

A

multidimensional array

Chapter 6 (page 350)

91
Q
$Fruits = array("Banana", "Apple", "Apple", "Mango", "Orange", "Pear");
unset($Fruits[0], $Fruits[4];
array_unique($Fruits);
unset($Fruits[0]);
$Result = in_array("Apple", $Fruits);

What is the value of $Fruits? $Result? (tricky)

a) Apple, Mango, Pear/ True
b) Mango, Pear/ False
c) Apple, Apple, Mango, Pear/True
d) Mango, Orange, Pear/False

A

Apple, Apple, Mango, Pear/True

  • unset () Removes Banana and Orange
  • array_unique() returns a new array which isn’t used
  • unset() #2 does nothing because unset retains indexes and $Fruits[0] was already removed
92
Q

$Names = array(‘John”=>”Oliver”, “Jimmy”=>”Fallon”, “Stephen”=>”Colbert”);
SNames2 = array_slice($Names, 0, 2);
ksort($Names2);

What are the value of $Names2

a) Oliver, Fallon
b) Oliver, Fallon, Colbert
c) Fallon, Oliver
d) Colbert, Fallon, Oliver

A

b) Fallon, Oliver
Colbert is removed and then this is sorted by keys (Fallon, Oliver are the values)

Chapter 6

array_slice() function returns a portion of an array and assigns it to another array

array_slice() function syntax:
array_slice(array_name, start, number_to_return);

ksort() and krsort() is the most commonly used array sorting functions fro associative arrays

93
Q

$Ounces = array(“ounces”=>1, “cups”=>”0.125,
“pints”=>0.0625, “quarts”=>0.03125, “gallons”=>0.0078125);
$Cups = array(“ounces”=>8, “cups”=>1, “pints”=>0.5, “quarts”=>0.25, “gallons”=>0.0625);
$Measures = array(“Ounces”=>$Ounces, “Cups”=>$Cups);

What is the value at $Measure[“Ounces”][“cups”]?

a) 0.125
b) 1
c) 8
d) 0.25

A

a) 0.125

Chapter 6

94
Q

You create one-to-many relationships when you want to break information into multiple, logical sets. True or False?

A

False

Chapter 7 (page 384)
You create a one-to-many relationship to eliminate redundant information in a single table.
95
Q

Database management systems can run on only a single platform. True or False?

A

False

Chapter 7 (page 388)
A DBMS runs on many different platforms, ranging from personal computers to network servers, and different DBMSs exist for different types of database format.
96
Q

A related table is the main table in a relationship that is referenced by another table. True or False?

A

False

Chapter 7

A related table (or “child table”) references a primary table in a relational database.
A primary table is the main table in a relationship that is referenced by another table.

97
Q

To make a specific database active, you must execute the ___ database statement.

a) CHANGE
b) USE
c) SWITCH
d) SELECT

A

USE

Chapter 7

98
Q

The ___ keyword is used with the ALTER TABLE statement to rename a column in a table.

a) RENAME
b) MODIFY
c) CHANGE
d) REPLACE

A

CHANGE

Chapter 7

99
Q

To delete a database, you must execute the ___ DATABASE command.

a) DELETE
b) REMOVE
c) DROP
d) EXIT

A

DROP

Chapter 7

100
Q

To summarize data in a set of records, you use a family of functions called ___ functions.

a) aggregate
b) summary
c) statistical
d) group

A

aggregate

Chapter 7

Aggregate functions summarize data in record sets rather than display the individual records.

101
Q

You can specify which records to return from a database by using the ___ keyword.

a) CRITERIA
b) MATCH
c) LIKE
d) WHERE

A

WHERE

Chapter 7

102
Q

The ___ keyword is used with the ALTER TABLE statement to rename a table.

a) RENAME
b) MODIFY
c) CHANGE
d) REPLACE

A

RENAME

Chapter 7

103
Q

phpMyAdmin provides a convenient method of transferring files from the development server to the production server using the ___ process.

a) download/upload
b) source/destination
c) browse/select
d) export/import

A

export/import

Chapter 7

104
Q

Apache, PHP, and MySQL are all examples of open-source software. True or False?

A

True

Chapter 7

105
Q

For simple collection of information, flat-file databases are usually adequate. True or False?

A

True

Chapter 7

106
Q

SQL stands for sequential query language. True or False?

A

False

Chapter 7 (page 389)
SQL or structured query language (sometimes pronounces sequel), is a standard data manipulation language among many DBMSs.
107
Q

The ___ portion of the SELECT statement determines which fields to retrieve from a table.

a) attribute
b) criteria
c) command
d) select

A

criteria

Chapter 7

108
Q

To modify the structure of a table, you use the ___ TABLE statement

a) MODIFY
b) ALTER
c) CHANGE
d) UPDATE

A

ALTER

Chapter 7

109
Q

The ___ statement is used to take away privileges from an existing user account from a specified table or database.

a) REMOVE
b) DROP
c) DELETE
d) REVOKE

A

REVOKE

Chapter 7

110
Q

Use the ___ statement to add multiple records from an external file to a database table.

a) INSERT_RECORDS
b) ADD_RECORDS
c) INSERT_DATA
d) LOAD_DATA

A

LOAD_DATA

Chapter 7
The LOAD_DATA statement, with the full path and name of local text file, is used to add multiple records to a table.

111
Q

Which statement has the correct syntax to add data to the table “company_cars”?

a) INSERT INTO company_cars (license, make, model, miles, model year) VALUES(“6GACY238”, “Toyota”, “Corolla”, 60000, 2011);
b) INSERT INTO company_cars (license, make, model, miles, model year)
c) SELECT INTO company_cars VALUES(“6GACY238”, “Toyota”, “Corolla”, 60000, 2011);
d) INSERT INTO company_cars VALUES(“6GACY238”, “Toyota”, “Corolla”, 60000, 2011);

A

a) INSERT INTO company_cars (license, make, model, miles, model year) VALUES(“6GACY238”, “Toyota”, “Corolla”, 60000, 2011);
d) INSERT INTO company_cars VALUES(“6GACY238”, “Toyota”, “Corolla”, 60000, 2011);

Chapter 7

112
Q

Which statement will count the number of unique makes?

a) SELECT DISTINCT (make) FROM company_cars
b) SELECT COUNT make FROM company_cars
c) COUNT DISTINCT make FROM company cars
d) SELECT DISTINCT make FROM company_cars

A

a) SELECT DISTINCT (make) FROM company_cars
d) SELECT DISTINCT make FROM company_cars

Chapter 7

113
Q

Which statement will sort Toyotas by number of miles ascending?

a) SELECT * FROM company_cars ORDER BY miles
b) SELECT * FROM company_cars ORDER BY miles WHERE make=”Toyota”
c) SELECT * FROM company_cars WHERE make=”Toyota” ORDER BY miles
d) SELECT * FROM company_cars WHERE “Toyota” ORDER BY miles

A

d) SELECT * FROM company_cars WHERE “Toyota” ORDER BY miles

Chapter 7

Use the ORDER BY keyword with SELECT statement to perform an alphanumeric sort of the results returned from a query

114
Q

One of the most popular PEAR code modules is PEAR DB, which simplifies access between PHP and database server. True or False?

A

True

Chapter 8

115
Q

The mysql_fetch_assoc() function returns the fields into an associative array and uses each row name as the array key. True or False?

A

False

Chapter 8

116
Q
The mysql_delete_db("dbname"[connection]);
 script is used to delete a database.  True or False?
A

False

Chapter 8

117
Q

The list of records that is returned from a mysql_query() is called a ___.

a) recordset
b) resultset
c) result
d) result query

A

resultset

Chapter 8

118
Q

The mysql_info() function only returns query information when you add ___ records with the INSERT keyword.

a) one
b) more than one
c) less than five
d) no records

A

more than one

Chapter 8

119
Q

The ___ keyword, often used with the primary key, requires that the field include a value.

a) NOT NULL
b) NOT BLANK
c) NOT EMPTY
d) NOT VOID

A

NOT NULL

Chapter 8

120
Q

Almost every command sent to MySQL from PHP is executed with the ___ function.

a) mysql_connect()
b) mysql_query()
c) mysql_select()
d) mysql_send()

A

mysql_query()

Chapter 8

121
Q

To delete records in a table, use the keywords ___.

a) DELETE, RECORD
b) DELETE, WHERE
c) REMOVE, WHERE
d) REMOVE, RECORD

A

DELETE, WHERE

Chapter 8

122
Q

The function ___ returns the field in the current row into an indexed array.

a) mysql_fect_assoc()
b) mysql_data_seek()
c) mysql_fetch_row()
d) mysql_fetch_lengths()

A

mysql_fetch_row()

Chapter 8

The mysql_fetch_row() function returns the fields in the current row of a resultset into an indexed array and moves the result pointer to the next row.

123
Q

To delete a database, use the ___ function.

a) mysql_delete_db()
b) mysql_drop_db()
c) mysql_delete_database()
d) mysql_drop_database()

A

mysql_drop_db()

Chapter 8

124
Q

The mysql_error() function returns a value of FALSE if it detects an error. True or False?

A

False

Chapter 8

125
Q

You pass the mysql_affected_rows() function the variable containing the result pointer from the mysql_query() function. True or False?

A

False

Chapter 8

With queries that modify tables but do not return results (INSERT, UPDATE and DELET queries), use the mysql_affected_rows() function to determine the number of affected rows.

126
Q

You can suppress error message by using the error control operator (%). True or False?

A

False

Chapter 8
Use the error control operator (@) to suppress error messages

127
Q

To add multiple records to a database from an external file, you use the ___ statement with the name of the local text file that contains the records you want to add.

a) INSERT DATA
b) LOAD DATA
c) INSERT RECORDS
d) UPLOAD RECORDS

A

LOAD DATA

Chapter 8

128
Q

The ___ command with a mysql_query() function executes successfully if the table already exists.

a) SHOW EXISTING TABLE
b) SHOW TABLES LIKE
c) SHOW MATCHING TABLE
d) SHOW SAME TABLE

A

SHOW TABLES LIKE

Chapter 8

129
Q

To return information about the MySQL database server version, use the ___ function.

a) mysql_get_client_info()
b) mysql_host_info(connection)
c) mysql_get_proto_info(connection
d) mysql_get_server_info(connection)

A

d) mysql_get_server_info(connection)

Chapter 8

130
Q

To change records in a table, use the UPDATE keyword to specify the name of the table to update and the ___ keyword to specify the value to assign to the fields in the records that match the condition in the WHERE keyword.

a) CHANGE
b) INSERT
c) SET
d) PUT

A

SET

Chapter 8

131
Q

What should always be the first step when querying a SQL DB using ODBC?

a) Create the DB or Table
b) Initialize the SQL server DB connection
c) Run error checks
d) Close old SQL sessions

A

Initialize the SQL server DB connection

Chapter 8

132
Q

Which function would you call to return the number of results after querying a DB?

a) mysql_num_fields()
b) mysql_fetch_row()
c) mysql_fetch_assoc()
d) mysql_num_rows()

A

d) mysql_num_rows()

Chapter 8

The mysql_num_rows() function returns the number of rows in a query result.

133
Q

You use the path argument t share cookies across multiple servers in the same domain. True or False?

A

False

Chapter 9
The domain argument is used for sharing cookies across multiple servers in the same domain.

134
Q

A hidden form field is not displayed by the browser. True or False?

A

True

Chapter 9

135
Q

Cookies were originally created for use with CGI scripts. True or False?

A

True

Chapter 9

136
Q

You can use a query string to pass information from one Web page to another. True or False?

A

True

Chapter 9
A query string is a set of name=value pairs appended to a target URL

137
Q

The setcookie() function has no required arguments. True or False?

A

False

Chapter 9
The syntax for the setcookie() function is:
setcookie(name [value, expires, path, domain, secure])
You must pass each of the arguments in the order specified in the syntax.
To skip the value, path, and domain arguments, specify an empty string as the argument value.
To skip the expires and secure arguments, specify 0 as the argument value

138
Q

You cannot append a query string to any URL on a Web page. True or False?

A

False

Chapter 9

A query string is a set of name=value pairs “appended” to a target URL.

139
Q

For a cookie to persist beyond the current browser session, you must use the ___ argument with the setcookie() function.

a) path
b) secure
c) domain
d) expires

A

expires

Chapter 9

The expires argument determines how long a cookie can remain on a client system before it is deleted.
To specify a cookie’s expiration time, use PHP’s time() function

140
Q

Cookies can be temporary or __.

a) hidden
b) relational
c) persistent
d) invisible

A

persistent

Chapter 9

Temporary cookies remain available only for the current browser session
Persistent cookies remain available beyond the current browser session and are stored in a text file on a client computer.

141
Q

Cookies that are available to the current Web page are automatically assigned to the ___ autoglobals.

a) $_GET
b) $_POST
c) $_FIND
d) $_COOKIE

A

$_COOKIE

Chapter 9

142
Q

Which of the following characters would encoding not encode?

a) ,
b) %
c) ^
d) /

A

d) /

Chapter 9

143
Q

You separate individual name=value pairs within a query string using ___.

a) backlashes ()
b) ampersand (&)
c) question mark (?)
d) forward slashes (/)

A

b) ampersand (&)

Chapter 9

144
Q

Session state information is stored in the ___ autoglobal.

a) $_GET[]
b) $_COOKIE[]
c) $_SESSION[]
d) $_POST[]

A

c) $_SESSION[]

Chapter 9

Session state information is stored in the $_SESSION autoglobal.
When the session_start() function is called, PHP either initializes a new $_SESSION autoglobal or retrieves any variables for the current session (based on the session ID) into the $_SESSION autoglobal.

145
Q

The ___ argument determines the availability of a cookie to other Web pages on a server

a) expires
b) domain
c) secure
d) path

A

path

Chapter 9
The path argument determines the availability of a cookie to other Web pages on a server.
Using the path argument allows cookies to be shared across a server.
A cookie is available to all Web pages in a specified path as well as all subdirectories in the specified path.

146
Q

___ are random alphanumeric strings that identifies a session.

a) hidden form fields
b) functions
c) session IDs
d) Cookies

A

Session IDs

Chapter 9
The session_start() function generates a unique session ID to identify the session.
147
Q

Whenever you need to work with sessions in a PHP script, you must call the ___ function.

a) session_start()
b) set_cookie()
c) keyword()
d) session_stop()

A

session_start()

Chapter 9

You must call the session_start() function before you send the Web browser any output.

148
Q

How many name=value pairs are in the following URL?
<a></a>

A

three

Chapter 9

Separate individual name=value pairs within the query string using ampersands (&)
A question mark (?) and a query string are automatically appended to the URL of a server_side script for any forms that are submitted with the GET method

149
Q

If you want to store state information that will be available when a client revisits your Web site in the future, you must use ___.

a) sessions
b) autoglobals
c) cookies
d) hidden form fields

A

cookie

Chapter 9

Cookie, or magic cookies, are small pieces of information about a user that are stored by a Web server in text files on the user’s computer

150
Q

Which of the following is not a tool for maintaining state information with PHP?

a) cookies
b) hidden form fields
c) sessions
d) functions

A

functions

Chapter 9
The four tools for maintaining state information with PHP are:
*  Hidden form fields
*  Query strings
*  Cookies
*  Sessions