Site icon sharedsapience.info

PHP FTP Function Mini-Quiz: From ftp_nb_fget() to ftp_raw().

The ftp_nb_fget PHP FTP function, sized for mobile viewing.

An image of the ftp_nb_fget() PHP FTP function, sized for mobile viewing.

HOW THE QUIZ WORKS:

Clicking the ‘randomize’ button situated above the reference table generates a new table whereby the function descriptions, function syntaxes, and function return values are randomized. The quiz involves matching the function descriptions, function syntaxes, and function return values to the correct function name. Information relating to the randomization of table cells will be displayed for three seconds, before disappearing.

On a desktop computer, table elements are selected by left-clicking the desired table cell and holding the left click in the mouse down position for one second before releasing the left click. The text inside the table cell will turn red to indicate that the one-second mouse left-click has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second left mouse-click process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second left mouse-click process on the original table cell.

To select a table element on a touchscreen device (mobile, tablet), simply touch the desired table cell and maintain the touch for one second before removing your finger from the screen. The text inside the table cell will turn red to indicate that the one-second touch has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second touch process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second touch process on the original table cell.

Normal touchscreen scrolling behaviour is exhibited by the cells with a light green background; cells without a light green background will not respond to normal touchscreen scrolling. The table is positioned in such a way that the user can also initiate touchscreen scrolling by swiping to the right or left of the table.

When a row consists of the correct function name, function description, function syntax, and function return value, the background colour of the row will change from ‘transparent’ to ‘khaki’; this provides visual feedback that the row is complete.

Once the entire table is complete, a paragraph of feedback will congratulate the user and provide the following information: date and time of quiz commencement; date and time of quiz completion; and the length of time it took the user to complete the quiz.

VIEWPORT OPTIONS:

An example of the layout designed for mobile phones
An example of the layout designed for tablets
An example of the layout designed for desktop computers

PURPOSE:

This webpage serves two purposes:

  1. It provides a reference table for the PHP FTP functions, with information extracted and condensed from w3schools.com and php.net.
  2. It enables users to complete a quiz related to the PHP FTP functions.

USAGE:

For each FTP function there are four table cells of information: the function name; the function description; the function syntax; and the function return value. There are three layouts available – ‘mobile‘, ‘tablet‘, and ‘desktop‘.

Click the relevant button below to display the PHP FTP functions reference table, sized appropriately for the desired viewport. A ‘RANDOMIZE‘ button appears above the reference table once the viewport is selected; clicking this button facilitates the commencement of a quiz.



Click the ‘RANDOMIZE‘ button to randomize the functional descriptions, the functional syntaxes, and the functional return information.


FUNCTION NAME FUNCTION DESCRIPTION FUNCTION SYNTAX FUNCTION RETURN VALUE
ftp_nb_fget()

[ftp_nb_fget – Retrieves a file from the FTP server and writes it to an open file (non-blocking)]

This function retrieves [‘gets’] remote_file from the FTP server in an asynchronous [‘non-blocking’] manner. ftp_nb_fget(ftp_stream, file_pointer, remote_file, mode [optional parameter with a default value of FTP_IMAGE], resumepos [optional parameter, with a default value of 0]);

[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. resumepos represents the position in remote_file to start downloading from.]

ftp_nb_fget(): returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA.
ftp_nb_fput()

[ftp_nb_fput – Uploads the data from an open file to the FTP server (non-blocking)]

This function uploads [‘puts’] data from the open file_pointer to remote_file on the FTP server, in an asynchronous [‘non-blocking’] manner. ftp_nb_fput(ftp_stream, remote_file, file_pointer, mode [optional parameter, with a default value of FTP_IMAGE], startpos [optional parameter, with a default value of 0]);

[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. startpos represents the position in remote_file to start uploading to.]

ftp_nb_fput(): returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA.
ftp_nb_get()

[ftp_nb_get – Retrieves a file from the FTP server and writes it to a local file (non-blocking)]

This function retrieves [‘gets’] remote_file from the FTP server and saves it into local_file, in an asynchronous [‘non-blocking’] manner. ftp_nb_get(ftp_stream, local_file, remote_file, mode [optional parameter with a default value of FTP_IMAGE], resumepos [optional parameter, with a default value of 0]);

[mode represents the transfer mode, and must be either FTP_ASCII or FTP_BINARY. resumepos specifies the position in remote_file to start downloading from.]

ftp_nb_get(): returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA.
ftp_nb_put()

[ftp_nb_put – Stores a file on the FTP server (non-blocking)]

This function uploads [‘puts’] local_file to the FTP server, in an asynchronous [‘non-blocking’] manner. ftp_nb_put(ftp_stream, remote_file, local_file, mode [optional parameter, with a default value of FTP_IMAGE], startpos [optional parameter, with a default value of 0]);

[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. startpos represents the position in remote_file to start uploading to.]

ftp_nb_put(): returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA.
ftp_nlist()

[ftp_nlist – Returns a list of files in the given directory]

This function returns an array [a ‘numbered list’] of files in the given directory on the FTP server. ftp_nlist(ftp_stream, directory);

[directory represents the directory to be listed. This parameter can also include arguments, but is not escaped – so there may be some issues with filenames containing spaces and other characters.]

ftp_nlist(): returns an array of filenames from directory on success; FALSE on error.
ftp_pasv()

[ftp_pasv – Turns passive mode on or off]

In passive mode data connections are initiated by the client rather than the FTP server — this may be needed if the client is behind a firewall. This function turns passive mode on or off, and can only be called after a successful login – otherwise it will fail. ftp_pasv(ftp_stream, pasv);

[If pasv is TRUE then passive mode is turned on; otherwise it is turned off.].

ftp_pasv(): returns TRUE on success; FALSE on failure.
ftp_put()

[ftp_put – Uploads a file to the FTP server]

This function uploads [‘puts’] local_file into remote_file on the FTP server. ftp_put(ftp_stream, remote_file, local_file, mode [optional parameter with a default value of FTP_IMAGE], startpos [optional parameter with a default value of 0]);

[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. startpos represents the position in remote_file to start uploading to.]

ftp_put(): returns TRUE on success; FALSE on failure.
ftp_pwd()

[ftp_pwd – Returns the current directory name]

This function returns the name of the present working directory of the FTP server. ftp_pwd(ftp_stream);
ftp_pwd(): returns the current [‘present’] working directory name on success; FALSE on error.
ftp_raw()

[ftp_raw – Sends an arbitrary command to an FTP server]

This function sends an unrefined [‘raw’] FTP command to the FTP server. ftp_raw(ftp_stream, command); ftp_raw(): returns the server’s response as an array of strings. No parsing is performed on the response string, and the success or otherwise of the command is not determined.

Web design certified by:
Click images for proof of certification.


Exit mobile version