Review Exercises

What is an absolute path? What is a relative path?

An absolute path references a file starting from the root directory of the computer:eg.,include ('C:/php/includes/ ➝ file.php');

A relative path uses the referencing (parent) file as the starting point.To move up one folder, use two periods together. To move into a folder, use its name followed by a slash.

What is the difference between include( ) and require( )?

The include( ) and require( ) functions are exactly the same when working properly but behave differently when they fail. If an include( ) function doesn’t work (it cannot include the file for some reason), a warning will be printed to the Web browser A, but the script will continue to run. If require( ) fails, an error is printed and the script is halted B.

What is the difference between include( ) and include_once( )? Which function should you generally avoid using and why?

include_one() which guarantees that the file in question is included only once regardless of how many times a script may (presumably inadvertently) attempt to include it.include_ once( ) require extra work from the PHP module (i.e., PHP must first check that the file has not already been included), it’s best

Why does it not matter what extension is used for an included file?

that PHP will treat the included code as HTML (i.e., send it directly to the browser) unless the file contains code within the PHP tags.

What is the significance of the $_SERVER['REQUEST_METHOD'] value?

to know the HTML form handling method use $_SERVER['REQUEST_METHOD']

When you have a form that uses the POST method and gets submitted back to the same page, two different types of requests will be made of that script.The first request, which loads the form, will be a GET request.When the form is submitted, a second request of the script will be made, this time a POST request (so long as the form uses the POST method).

How do you make the following form elements sticky? > Text input > Select menu > Radio button > Check box > Textarea

A sticky form is simply a standard HTML form that remembers how you filled it out. for text input, value="", for select menu,selected="selected",radio button,checked="checked"

If you have a PHP error caused by code placed within an HTML tag, where must you look to find the error message?

HTML tag, and

What is the syntax for defining your own function?

function function_name ( ) {// Function code.}

What is the syntax for defining a function that takes arguments?

function print_hello ($first, $last) {// Function code.}