Chapter 7 - Practical PHP Flashcards
What is printf conversion specifier would you use to display a floating point number?
The conversion specifier you would use to display a floating-point number is %f.
What printf statement could be used to take the input string “Happy Birthday” and output the string “**Happy”?
To take the input string “Happy Birthday” and output the string “**Happy”, you could use a printf statement such as: printf(“%’*7.5s”, “Happy Birthday”);
To send the output from printf to a variable instead of to a browser, what alternative function would you use?
To send the output from printf to a variable instead of to a browser, you would use sprintf instead.
How would you create a Unix timestamp for 7:11 am. on May 2, 2016?
To create a Unix timestamp for 7:11am on May 2nd 2016, you could use the command: $timestamp = mktime(7, 11, 0, 5, 2, 2016);
Which file access mode would you use with fopen to open a file in write and read mode, with the file truncated and the file pointer at the start?
You would use the “w+” file access mode with fopen to open a file in write and read mode, with the file truncated and the file pointer at the start.
What is the PHP command for deleting the file file.txt?
The PHP command for deleting the file file.txt is: unlink(‘file.txt’);
Which HP function is used to read in an entire file in one go, even from across the web?
The PHP function file_get_contents is used to read in an entire file in one go. It will also read them from across the Internet if provided with a URL.
Which PHP superglobal variable holds the details on uploaded files?
The PHP superglobal associative array $_FILES contains the details about uploaded files.
Which PHP function enables the running of system commands?
The PHP exec function enables the running of system commands.
Which of the following tag styles is preferred in HTML5? <hr> or <hr>?
In HTML5 you can use either the XHTML style of tag (such as <hr>) or the standard HTML4 style (such as <hr>). It’s entirely up to you or your company’s coding style.