• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/41

Click to flip

41 Cards in this Set

  • Front
  • Back
  • 3rd side (hint)
The PHP date() function formats a timestamp to a more readable date and time.

What is the syntax of the PHP date() function?
date(format,timestamp)
The PHP date() function syntax contains two parameters, format and timestamp, which one of those is optional?
timestamp
If the PHP date() function does NOT contain the optional timestamp, what happens?
It uses the default, which is the current date and time. (as a timestamp)
What is a Timestamp?
The number of seconds since January 1, 1970 at 00:00:00 GMT.
The first parameter in the date() function specifies how to format the date/time. It uses the letters to d, m and y to represent date and time formats. What characters can be inserted between the three letters to add additional formatting?
/ (backslash)
. (period)
- (dash)
The mktime() function returns the Unix timestamp for a specified date. What is the syntax for mktime()?
mktime(hour,minute,second,month,day,year,is_dst)
What would this code do?

<?php
$time = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
echo .date("Y/m/d/", $time);
?>
This would display the date and time 24 hours from the current time.
You can insert the content of a file into a PHP file before the server executes it, with the include() or require() function. The two functions are identical in every way, except one. How do they differ?
They each handle errors differently. The include() function generates a warning (but the script will continue execution) while the require() function generates a fatal error (and the script execution will stop after the error).
______ ____ ________ are used to create functions, headers, footers, or elements that will be reused on multiple pages.
Server Side Includes (SSI)
The include() function takes all the text in a specified file and copies it into the file that uses the include function. What is the syntax for the include() function?
<?php include("filename.php"); ?>
The require() function takes all the text in a specified file and copies it into the file that uses the include function. What is the syntax for the require() function?
<?php include("filename.php"); ?>
The fopen() function is used to open files in PHP. The first parameter of this function contains the name of the file to be opened and the second parameter specifies in which mode the file should be opened. What are the 8 modes that can be used?
r -Read only. Starts at the beginning of the file
r+ -Read/Write. Starts at beginning of the file
w -Write only. Opens and clears the contents of file; or creates a new file if it doesn't exist
w+ -Read/Write. Opens and clears the contents of file; or creates a new file if it doesn't exist
a -Append. Opens and writes to the end of the file or creates a new file if it doesn't exist
a+ Read/Append. Preserves file content by writing to the end of the file
x -Write only. Creates a new file. Returns FALSE and an error if file already exists
x+ -Read/Write. Creates a new file. Returns FALSE and an error if file already exists
The _____() function is used to close an open file.
fclose()
<?php
$file = fopen("test.txt","r");

//some code to be executed

_____($file);
?>
The feof() function checks if the "end-of-file" (EOF) has been reached. What would be the most common use for this function?
The feof() function is useful for looping through data of unknown length.
The _____() function is used to read a single line from a file.
fgets
The _____() function is used to read a single character from a file.
fgetc()
The ____="____" attribute of the <input> tag specifies that the input should be pocessed as a file. For example, when viewed in a browser, there will be a browse-button next to the input field
type="file"
Note: Allowing users to upload files is a big security risk. Only permit trusted users to perform file uploads.
By using the global PHP $_FILES array you can upload files from a client computer to the remote server. What is the first parameter?

$_FILES["____"]["____"]
The first parameter is the form's input name.
By using the global PHP $_FILES array you can upload files from a client computer to the remote server. What are the 5 values of the second index?

$_FILES["____"]["____"]
The 5 values of the second index are:

"name"
"type"
"size"
"tmp_name"
"error"
The 5 values of the $_FILES second index are: "name", "type", "size", "tmp_name", and "error". What do these values represent?
$_FILES["file"]["name"] - the name of the uploaded file

$_FILES["file"]["type"] - the type of the uploaded file

$_FILES["file"]["size"] - the size in bytes of the uploaded file

$_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server

$_FILES["file"]["error"] - the error code resulting from the file upload
The setcookie() function is used to set a cookie. What is the syntax for this function?
setcookie(name, value, expire, path, domain);


The setcookie() function is used to set a cookie. Where in the code should this function go?
The setcookie() function must appear BEFORE the <html> tag.
The value of a cookie is automatically URL encoded when sending the cookie, and automatically decoded when received. To prevent URL encoding, use ____________() instead.
setrawcookie()
What PHP variable is used to retrieve a cookie value?
$_COOKIE
What PHP function is used to find out if a cookie has been set?
isset()
When deleting a cookie you should assure that the expiration date is in the past. What is the syntax for deleting a cookie that was set one hour ago?
setcookie("user", "", time()-3600);
If your application deals with browsers that do not support cookies, you will have to use other methods to pass information from one page to another in your application. One method is to pass the data through _____ and ____ _____.
forms and user input
In a PHP session, before you can store user information you must first start up the session. What is the syntax for starting a session?
<?php session_start(); ?>
Where does the code for starting a PHP session go?
The session_start() function must appear BEFORE the <html> tag.
The correct way to store and retrieve session variables is to use the PHP _________ variable.
$_SESSION
If you wish to delete some session data, you can use the _____() function, which is used to free the specified session variable.
unset()
If you wish to delete some session data, you can use the session_destroy() function, which is used to completely destroy the session. What is the syntax for this?
<?php session_destroy(); ?>
Note: This function will reset your session and you will lose all your stored session data.
The PHP mail() function is used to send emails from inside a script. What is the syntax for this function?
mail(to,subject,message,headers,parameters)
Note: For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file. Read more in our PHP Mail reference.
True or False? PHP does not require an installed and working email system for the mail functions to be available.
False
The program to be used is defined by the configuration settings in the php.ini file.
The PHP mail() function is used to send emails from inside a script. Which parameters of the function are required?

Syntax:

mail(to,subject,message,headers,parameters)
"to", "subject" and "message" are required.
Note: For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file. Read more in our PHP Mail reference.
The PHP mail() function is used to send emails from inside a script. What are the restrictions on the "subject" parameter?
"subject" is a required parameter, which cannot contain any newline characters.
The PHP mail() function is used to send emails from inside a script. What are the restrictions on the "message" parameter?
The "message" parameter is required, each line should be separated with a LF (\n). Lines should not exceed 70 characters
The PHP mail() function is used to send emails from inside a script. What are the restrictions on the "header" parameter?
The "header" parameter is optional, it specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n)
Basic Error Handling: What does the die() function do?
Similar to exit() — it will output a message and terminate the current script.
Creating a custom error handler is quite simple. We simply create a special function that can be called when an error occurs in PHP.

This function must have be able to handle a minimum of two parameters, but can accept up to five. Name all five and indicate which two are required.
The minimum two parameters are error level and error message.

The three other parameters that can be included are file, line-number, and error context
What is the syntax for creating a Custom Error Handler?
error_function(error_level,error_message, error_file,error_line,error_context)
Has 2 parameters that are required and 3 that are not.