Question #2 (244-4). What is the escape sequence for a single quotation mark? ANSWER: " To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash before a single quote, or at the end of the string, double it (\\). Note that attempting to escape any other character will print the backslash too...Note: Unlike the two other syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings. " - PHP Manual
Questions #3 (244-8). Which of the following functions returns the number of occurrences of a substring? String Functions-w3schools
Question #4 (245-12). Which of the followingfunctions allows you to replace characters within a specified portion of a string?
Question #5 (245-14). If you specify an empty string as the second argument of the strtok() function or if the string does not contain any of the separators you specify, the strtok() function returns a value of false. True or False? ANSWER: "it is only the first call to strtok() that uses the string argument. After the first call, this function only needs the split argument, as it keeps track of where it is in the current string. To tokenize a new string, call strtok() with the string argument again" - w3schools
ANSWER: brooklyn.cuny.edu - Strings(ppt) "The strtok() function returns the entire string if: An empty string is specified as the second argument of the strtok() functtion; The string does not contain any of the separators specified"
Question #6 (245-16). String comparison operators and most string comparison functions compare individual characters according to their ASCII position. True or False? ANSWER: There is only one string operator in PHP. The concatenation operator (.) is used to put two string values together.w3schools:
ANSWER: bin2hex(), chr(), count_chars(), ord() - specifically cite ASCII characters
ANSWER: brooklyn.cuny.edu - Strings (ppt) "Most string comparison functions compare strings based on their ASCII values." p. 36
Question #7 (246-18). You should always rely on JavaScript code to perform data validation. True or False?
ANSWER: "User input should be validated on the browser whenever possible (by client scripts). Browser validation is faster and reduces the server load. You should consider server validation if the user input will be inserted into a database. A good way to validate a form on the server is to post the form to itself, instead of jumping to a different page. The user will then get the error messages on the same page as the form. This makes it easier to discover the error." - PHP Forms (w3schools)
Question #8 (246-20). If you want to ensure that a form variable is of a specific numeric data type, such as an integer, you should first use the is_numeric() function to test whether the variable is numeric, then cast the variable to the required data type. True or False?
EXAMPLE: is_numeric - from plus2net
if (!is_numeric($quantity))
{
echo 'is not numeric';
}
ANSWER: "Be careful of validation by type when dealing with $_GET and $_POST variables. If someone inputs a number, is_numeric will not be true, because all information passed as GET and POST vars are strings. So to find out if a valid number has been supplied, you can either cast and then see if it is greater than 0. Or alternatively, check the string to see if it is only made of 0-9 characters." Symic.com
Question #9 (299-2). Which of the following is the correct syntax for opening a handle for reading only to a text file named prospects.txt? p. 249 and File Open, Tizag.com
Question #10 (299-4). A __________ is a special type of variable that refers to the currently selected line or character in a file.
ANSWER: "A file pointer is PHP's way of remembering its location in a file. When you open a file for reading, the file pointer begins at the start of the file. This makes sense because you will usually be reading data from the front of the file...However, when you open a file for appending, the file pointer is at the end of the file, as you most likely will be appending data at the end of the file. When you use reading or writing functions they begin at the location specified by the file pointer." - File Open - Tizag.com
Question #11 (300-6). Which of the following escape sequences is used on Macintosh platforms?
ANSWER: Mac in the Shell - mactech.com
ANSWER 2: Programming Escape Characters - wilsonmar.com
Question #12 (300-8). Which of the following constants can you use with the file_put_contents function to append data to the end of a file:
ANSWER: PHP Manual
FILE_USE_INCLUDE_PATH | Search for filename in the include directory. See include_path for more information. |
FILE_APPEND | If file filename already exists, append the data to the file instead of overwriting it. Mutually exclusive with LOCK_EX since appends are atomic and thus there is no reason to lock. |
LOCK_EX | Acquire an exclusive lock on the file while proceeding to the writing. Mutually exclusive with FILE_APPEND. |
FILE_TEXT | data is written in text mode. If unicode semantics are enabled, the default encoding is UTF-8. You can specify a different encoding by creating a custom context or by using the stream_default_encoding() to change the default. This flag cannot be used with FILE_BINARY. This flag is only available since PHP 6. |
FILE_BINARY | data will be written in binary mode. This is the default setting and cannot be used with FILE_TEXT. This flag is only available since PHP 6. |
Question #13 (300-10). What is the correct syntax for using the fwrite() function to assign a value "Forestville Foods" to a handle named $SalesProspects?
ANSWER: "fwrite() writes the contents of string to the file stream pointed to by handle." SYNTAX: int fwrite ( resource $handle , string $string [, int $length ] )" - PHP Manual;
EXAMPLE:
<?php
$fp = fopen('data.txt', 'w');
fwrite($fp, '1');
fwrite($fp, '23');
fclose($fp);
Question #14 (300-12). Which of the following operational constants can you use with the flock() function? (Choose all that apply.)
ANSWER: "The flock() function locks or releases a file...This function returns TRUE on success or FALSE on failure." - w3schools.com - flock(file,lock,block). Possible values for lock (required):
Question #15 (301-14). The file() function automatically recognizes whether the lines in a text file end in \n, \r, or \r\n. True or False?
ANSWER: "The file() reads a file into an array...Each array element contains a line from the file, with newline still attached. - w3schools
ANSWER 2 - PHP Manual:
"Note: Each line in the resulting array will include the line ending, unless FILE_IGNORE_NEW_LINES is used, so you still need to use rtrim() if you do not want the line ending present.
Note: If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the auto_detect_line_endings run-time configuration option may help resolve the problem."
Question #16 (301-16). Which of the following functions returns a value of true when a file pointer reaches the end of a file?
ANSWER: "What is a file pointer? It's the marker used by PHP to keep track of where the currently executing file operations take place. For instance, when a file is first created the file pointer is adjusted to the beginning of the file. Likewise, when a file is opened in append mode, the file is opened and the pointer points to the very end of the file." - Working with Files in PHP - O'Reilly.com
ANSWER: "The feof() function checks if the "end-of-file" (EOF) has been reached... The feof() function is useful for looping through data of unknown length...Note: You cannot read from files opened in w, a, and x mode!" - w3schools
Question #17 (301-18). Which of the following statements creates a directory named "students" at the same level as the current directory?
ANSWER: Microsoft Technet - "To create a directory named Taxes with a subdirectory named Property, which contains a subdirectory named Current, type: mkdir \Taxes\Property\Current. This is the same as typing the following sequence of commands with command extensions disabled:
mkdir \Taxes
chdir \Taxes
mkdir Property
chdir Property
mkdir Current"
Question #18 (355-1). Which of the following functions remove the first element from the beginning of an array? w3schools; p. 155 Text
Question #19 (355-3). Which of the following functions removes the last element from the end of an array? (Choose all that apply.)
Question #20 (355-5). After removing elements from an array, the unset() function automatically renumbers the remaining elements. True or False?
ANSWER: "If you delete an element by unset (say unset($foo[3]) the remaining elements stay in their originally entered order" - Dev.shed.com
Question #21 (355-7). What is the correct syntax for declaring and initializing an associative array?
EXAMPLE 1: Webucator - PHP Tutorial: Arrays
$Beatles = array(); $Beatles['singer1'] = 'Paul'; $Beatles['singer2'] = 'John'; $Beatles['guitarist'] = 'George'; $Beatles['drummer'] = 'Ringo';
EXAMPLE 2:
$Beatles = array('singer1' => 'John',
'singer2' => 'Paul',
'guitarist' => 'George',
'drummer' => 'Ringo');
Question #22 (355-9).If you declare an array in PHP and use a starting index other than 0, empty elements are created for each index between 0 and the index value you specify. True or False? SOURCE: PHP Manual - Arrays
EXAMPLE: PHP Manual
The above example will output:
Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 13 [4] => 1 [8] => 1 [9] => 19 )
ANSWER: "Syntax "index => values", separated by commas, define index and values. index may be of type string or integer. When index is omitted, an integer index is automatically generated, starting at 0. If index is an integer, next generated index will be the biggest integer index + 1. Note that when two identical index are defined, the last overwrite the first... Having a trailing comma after the last defined array entry, while unusual, is a valid syntax."
Question #23 (356-11). Which of the following functions returns the value of an element where an array's internal pointer is positioned? w3schools - Arrays
Question #24 (356-13). Which of the following locates a key named "Ford" in an array named $AutoMakers[]? see Eastern Illinois U
Question #25 (356-15). Which of the following functions perform a reverse sort on an array? (Choose all that apply.). PHP Array Functions - w3schools
Question #26 (356-17). If you use the array_merge() function with indexed arrays, all elements in on array are appended to another array and renumbered. True or False? ANSWER: Eastern Illinois U
Question #27 (409-1). A flat-file database consists of a single table. True or False?
Question #28 (409-3). What is the correct term for the individual pieces of information that are in a database record? ANSWER: Eastern Illinois U
Question #29 (410-9). What is the default value of the mysql command's -h argument? ANSWER: Eastern Illinois U
Question #30 (410-10). What character must terminate SQL commands in the MySQL Monitor? Eastern Illinois U
Question #31 (410-11). With what characters do you quote identifiers that include special characters? ANSWER: Eastern Illinois U
Question #32 (411-14). Which of the following statements displays the available databases in your MySQL installation? ANSWER: Eastern Illinois U
Question #33 (411-15). What's the first thing you should do after creating a new database? ANSWER: Eastern Illinois U
Question #34 (411-21). Which of the following is the correct string for a filter that narrows a recordset include only records in which the State filed is equal to Massachusetts? (Ignore double quotation marks that surround each answer choice.) ANSWER: Eastern Illinois U
Question #35 (466-2). Which of the following functions closes a database connection?
ANSWER: http://ngtech.org/forums/MIS4530/comments.php?DiscussionID=35 says the answer is NOT mysqli_free()!
Question #36 (467-4). What is the correct syntax for selecting a database with the mysqli_select_db() function?
ANSWER: Description: bool mysqli_select_db ( mysqli link, string dbname ) The mysqli_select_db() function selects the default database (specified by the dbname parameter) to be used when performing queries against the database connection represented by the link parameter. Note: This function should only be used to change the default database for the connection. You can select the default database with 4th parameter in mysqli_connect(). Return Values: Returns TRUE on success or FALSE on failure. (PHP Builder)
Question #37 (467-6). The following code structure prevents error messages from printing in the event that the database connection is not available. True or False?
$DBConnect = mysqli_connect("localhost", "dongosselin",
"rosebud", "flightlog");
if (!DBConnect)
echo "<p>The database server is not available.</p>";
else {
echo "<p>Successfully connected to the database server.</p>";
mysqli_close($DBConnect);
}
TEST:
Successfully connected to the database server.
Question #38 (467-8). Which of the following characters suppresses error messages in PHP?
ANSWER: "PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored. " - Error Control Operators, PHP Manual
Question #39 (468-10). Which is the following functions reports the error message from the last failed database connection attempt?
Question #40 (468-12). Which of the following functions returns the fields in the current row of a set into an indexed array?
Question #41 (469-18). Which of the following SQL keywords creates an autoincrementing field?
Question #42 (469-20). The __________ function returns the number of operations for various types of actions, depending on the type of query.
**************************************************************
**************************************************************