PHP Percolate! Season 6 (19 Chapters)

Student: Jim Merrikin



  • What is the significance of a form's method attribute? Of its action attribute?
  • The method attribute determines how data is SENT to the server. If it uses the POST method, data is hidden and not visible in the URL address bar. Using the GET method, data is passed as part of the URL and is publicly visible. Using the GET method is good when you want to be able to link directly to a page that depends on this information or used when requesting information.
    The action attribute specifies which file will receive the data from the form on submit.
  • 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?
  • An HTML form submitted by a PHP script is loaded through a URL so that the form data is passed to the server where additional action will take place. Using a form submit button without a URL would be restricted to client-side listeners and would not interact with the server.
  • What are the differences between using single and double quotation marks to delineate strings?
  • Double quotation marks allow variables data values to be displayed inside of a string. Single quotation marks will show the variable name but not it's corresponding value.
  • What control structures were introduced in this chapter?
  • Foreach loops, for loops, and while loops.
  • What new variable type was introduced in this chapter?
  • Array variable types were newly introduced in this chapter.
  • What operator tests for equality? What is the assignment operator?
  • The double equal sign is used to test for 'loose' equality between two or more states or values. Triple equal sign is used to test for 'strict' equality between two or more states or values. The assignment operator is the single equal sign.
  • Why are the textual form elements validated using empty() but other form elements are validated using isset()?
  • The isempty() function will return true if a text field contains an empty string, NULL, array(), or false. The isset() function is used to determine if a variable is set and is not NULL.
  • What is the difference between an indexed array and an associative array?
  • Indexed arrays using numeric keys whereas associative arrays use string-based keys.
  • With what value do indexed arrays begin (by default)? If an indexed array has ten elements in it, what would be the expected index of the last element in the array?
  • Indexed arrays are zero-based and the first item in an array begins with zero, ie: $myarray[0]. In an array with ten items, the tenth item would be accessed by accesing the array index of 9, ie: $myarray[9].
  • What are the superglobal arrays? From where do the following superglobals get their values?
    • $_GET
    • $_POST
    • $_COOKIE
    • $_REQUEST
    • $_SESSION
    • $_SERVER
    • $_ENV

    • $_GET receives its values from an HTML form whose method attribute is set to GET.
    • $_POST receives its values from an HTML form whose method attribute is set to POST.
    • $_COOKIE receives its values from any HTTP cookies which were set in the browser.
    • $_REQUEST receives its values from $_GET, $_POST, and $_COOKIE.
    • $_SESSION receives its values from variables stored in a user's session.
    • $_SERVER receives its values directly from the web server itself.
    • $_ENV receives its values from the environment in which PHP is currently running and are set by the system or shell.
  • 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.
  • An indivudal array item can be printed by accessing the array variable along with the position of the item you want. For instance to access the fourth item of a zero-based array you would use this syntax:
    An associateive array item can be accessed by using the variable name of the array along with its key value such as:
  • What does the count() function do?
  • The count() function is used to determine the length of an array.
  • What impact does printing \n have on the Web browser?
  • Printing \n inserts a newline character in the browser.
  • 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 foreach loop can only be used with arrays. For loops are faster than foreach and can be used with arrays or to create random loops. While loops are used to continue running a loop until some particular condition is reached.
  • What is the ++ operator? What does it do?
  • The ++ operator takes a value and adds 1 to it.