The Web Wizard's Guide to PHP

by David Lash

Test Bank

Chapter 86, Short Answer

1.What does the ereg() functioList at least 3 advantages using databases have over using filesn work.?

2. What is the IEEE: Posix 1003.2 standard?What is a primary key?

3. List at least 3 database types that PHP can use.

4. What is a disadvantage of using the TEXT MySQL data type for all database character string

values?What is a character class?

5. What is [:lower:]?Which MySQL data type would most efficiently store a number with value from 0-50,000?

Why is incremental design a useful technique to design a regular expression?

6. WList two different ways to create your initial MySQL tables. hat does the split() command function do?

6.7. What does AUTO INCREMENT argument define? Write a PHP statement that command to splits the string $x into the list $tokens separatedby the “:” character.

8. What SQL command is used to change a database table? does the ereg_replace() function command do?

9. What command would you use to read a file and store it in an array?Show an SQL command that searches through a table called NAMES and changes all items

from the COUNT column to have value 0.

10. Show an SQL command that retrieves all items from a table called INVENTORY.

11. Show an SQL command that retrieves all items from a table called INVENTORY with

values of COUNT greater than 100.

12. What does the mysql_fetch_row() function do and how is it used?

13. What does the NOT NULL MySQL argument attribute define?

14. What is an advantage of using an independent query language such as SQL?

15. What does the mysql_select_database() function do?

1.What is a file handle and when would you use one?Name 2 disadvantages of using hidden fields to pass data between HTML forms.

2.What does the fopen() command do?What is the mail() function used for and list at least 3 of its arguments.

3.Write a regular expression that matches a string that contains an @ sign and ends in “.com”What is the advantage of using the $_SESSION associative array?

4.What does the session_register() function do and how is it used? Write a regular expression that matches a string that contains only a group of three digits and then a group of four digits separated by a hyphen.

What areName at least 3 of PHP the file open modes.Describe how you can view your cookie data with Internet Explorer or Netscape. that PHP supports?

Where does the session_register() function store data that it registers?

Chapter 876, True/ False

  1. The mysql_select_db() function can be used to select a file or MySQL database instance. A regular expressions evaluate to specific numerical value. is a pattern that can be used to search and replace sequences in a character string.
    Data stored as cookies is save on the end-user’s local disk.

Answer: True FalseTrue

- Need to clarify the word sequences. That is specify sequences of characters.

  1. The ^ character can be used to anchor a pattern so it only matches at the end of a string. Answer: False – ^ matches at the startData saved in HTML cannot be viewed by the end-user.A MySQL table can be created from a PHP script.

Answer: TrueFalse

  1. Using the fopen() command, it is possible to open a file to read its contents and then replace the file with new information.
    Answer: TrueThe setcookie() function must be run before anything is output to the browser for it to work correctly.Data can be inserted into or deleted from MySQL tables using a PHP script.

Answer: TrueFalse

4. If you omit the third argument to the setcookie() function, your cookie will not be saved on disThe INT MySQL data type would be an efficient definition for a table item with numeric values from 100 - 60,000.

k.

Answer: FalseTrue

  1. 5. 5.The SQL WHICH clause can be used to search for specific records from a MySQL table. following statements show a valid way to register the value of $name using PHP session functions.

Answer: False

$name = “Pete”;

session_register( $name ); fputs() command reads a string from a file and puts it into a string variable.

Answer: False- You do not use the $ before a variable name with the session_register() function.

Chapter 876, Multiple Choice

4.1. The following statement would be true command ereg(“a+b*a+”, $x) is true for which of the following values of $x?

if ( ereg(“a+b*a+”, $x) ) { Data stored as PHP function might be stored asWhich SQL command can be used to input data into MySQL tables?

a)INPUTa cookie“aa”

b)INCLUDEa file“ab”

c)“ba”INSERTin the web browser

d)PUT“A” and “B”all of the above

e)none of the abovefputs()“B” and “C”

Answer: cda

2. WThat does the following statement do?he following command statement ereg(“[^aeiou][aeiou]” , $x) is true for which of the following values of $x?

if (ereg(“[^aeiou][aeiou]” , $x) ) {SELECT * FROM SCORES WHERE ( WEEK = 12 );session_register( color, size )

;

a. Returns all records from the SCORES table with the WEEK column equal to 12.

  1. Returns any table with WEEK equal to 12. “aa”
  2. Returns the WEEK value to 12 in the SCORES table. Registers “the values for PHP variables color
  3. Returns the SCORES column from the WEEK table with 12 entries.

Sets the WEEK column to 12 from the SCORES table.and size ab”

  1. “ba”

b.all of the aboveSets a cookie for PHP variables color and size

none of the above

Answer: Ac

3. Which SQL command can you use to change table entries? at does the following statement do?

$expire = time() + (60 * 60 * 24 );

setcookie( ‘fast’, ‘times’, $expire );

a)CHANGE

b)RESET

c)WHERE

d)UPDATE

e)DEFINE

Deletes a cookie called fast

Sets a cookie called times with value fast

Sets a cookie that will expire in 24 hours

a)None of the above

Answer: d

4. none of the aboveThe command following statement ereg(“(p|h)*” , $x) is true for which of the following values of $x?

if (ereg(“(p|h)*” , $x) ) {

b)“aa”

c)“ab”

d)“ba”

e)all of the above

f)none of the above

Answer: d

Which of the following are valid open modes for the fopen() functionWhat PHP function can you use to access the text of any MySQL error messages? ?

a)mysql_output_message()

b)mysql_error()

c)mysql_fetch_row()

d)mysql_select()

e)mysql_message()

c.Answer: br+

d.r

e.w+

f.a

g.all of the above

Answer: e

5.Which of the following is NOT necessarily an advantage of using a formal database over files? Which of the following commands operate on a file?

a)Faster access

b)Less complex design

c)Increased security

d)Better concurrent access

Easier to change data formatfile()

a)fopen()

b)fgets()

c)fputs()

d)e)all of the above

Answer: be

Questions for Web Wizard’s Guide to PHPChapter 6
Page 3 of 3