Chapter 2 - Review

Output
Show all Hide all
1Toggle answer visibilityWhat is the significance of a form’s method attribute? Of its action attribute?

A form's method attribute controls how any user data will be conveyed to the server for processing. Values correspond to the GET and POST HTTP Methods. The 'post' method will send the information 'silently', whereas the 'get' method will format any data as a series of key=value pairs appended to the main url, exposing the information to the browser as a bookmarkable and editable location. GET is the default method used if nothing is specified or an invalid value is entered. POST should be used for any forms requiring a more secure submission.

A form's action attribute should be a path to the server side file that will handle the form on submission. HTML5 requires this attribute to have a value to pass validation. To submit a form to itself, simply use a '#'.

2Why must an HTML form that gets submitted to a PHP script be loaded through a URL? What would happen upon submitting the form if it were not loaded through a URL?
3What are the differences between using single and double quotation marks to delineate strings?
4What control structures were introduced in this chapter?
5Toggle answer visibilityWhat new variable type was introduced in this chapter?
ARRAY - a non scalar data type for aggregating data in lists with either numerical or strings as their key.
6What operator tests for equality? What is the assignment operator?
7Why are textual form elements validated using empty() but other form elements are validated using isset()?
8What is the difference between an indexed array and an associative array?
9With what value do indexed arrays begin (by default)? If an indexed array has ten elements in it, what would the expected index be of the last element in the array?
10What are the superglobal arrays? From where do the following superglobals get their values? $_GET, $_POST, $_COOKIE, $_REQUEST, $_SESSION, $_SERVER, $_ENV
11How can you print an individual indexed array item? How can you print an individual associative array item? Note: there is more than one answer to both questions.
12What does the count() function do?
13What impact does printing \n have on the Web browser?
14Generally speaking, when would you use a while loop? When would you use a for loop? When would you use a foreach loop? What is the syntax of each loop type?
15What is the + operator? What does it do?
Source
<?php
$review = array(
	1=>array(
		'q'=>'What is the significance of a form’s method attribute? Of its action attribute?',
		'a'=>"<p>
			A form's <b>method attribute</b> controls how any user data will be conveyed to 
			the server for processing. Values correspond to the GET and POST HTTP Methods. The 'post' 
			method will send the information 'silently', whereas the 'get' method will format any data
			as a series of key=value pairs appended to the main url, exposing the information to the 
			browser as a bookmarkable and editable location. GET is the default method used if nothing 
			is specified or an invalid value is entered. POST should be used for any forms requiring a 
			more secure submission.
		 </p>
		 <p>
		 	A form's <b>action attribute</b> should be a path to the server side file that will handle
		  	the form on submission. HTML5 requires this attribute to have a value to pass validation. 
		  	To submit a form to itself, simply use a '#'.
		 </p>"
	),	
	2=>array(
		'q'=>'Why must an HTML form that gets submitted to a PHP script be loaded through a URL? What would happen upon submitting the form if it were not loaded through a URL?',
		'a'=>''
	),
	3=>array(
		'q'=>'What are the differences between using single and double quotation marks to delineate strings?',
		'a'=>''
	),
	4=>array(
		'q'=>'What control structures were introduced in this chapter?',
		'a'=>''
	),
	5=>array(
		'q'=>'What new variable type was introduced in this chapter?',
		'a'=>'ARRAY - a non scalar data type for aggregating data in lists with either numerical or strings as their key.'
	),
	6=>array(
		'q'=>'What operator tests for equality? What is the assignment operator?',
		'a'=>''
	),
	7=>array(
		'q'=>'Why are textual form elements validated using empty() but other form elements are validated using isset()?',
		'a'=>''
	),
	8=>array(
		'q'=>'What is the difference between an indexed array and an associative array?',
		'a'=>''
	),
	9=>array(
		'q'=>'With what value do indexed arrays begin (by default)? If an indexed array has ten elements in it, what would the expected index be of the last element in the array?',
		'a'=>''
	),
	10=>array(
		'q'=>'What are the superglobal arrays? From where do the following superglobals get their values? $_GET, $_POST, $_COOKIE, $_REQUEST, $_SESSION, $_SERVER, $_ENV',
		'a'=>''
	),
	11=>array(
		'q'=>'How can you print an individual indexed array item? How can you print an individual associative array item? Note: there is more than one answer to both questions.',
		'a'=>''
	),
	12=>array(
		'q'=>'What does the count() function do?',
		'a'=>''
	),
	13=>array(
		'q'=>'What impact does printing \n have on the Web browser?',
		'a'=>''
	),
	14=>array(
		'q'=>'Generally speaking, when would you use a while loop? When would you use a for loop? When would you use a foreach loop? What is the syntax of each loop type?',
		'a'=>''
	),
	15=>array(
		'q'=>'What is the + operator? What does it do?',
		'a'=>''
	)
);
include('templates/review.php');
?>