Chapter 7 - Practical PHP Flashcards

1
Q

What is printf conversion specifier would you use to display a floating point number?

A

The conversion specifier you would use to display a floating-point number is %f.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What printf statement could be used to take the input string “Happy Birthday” and output the string “**Happy”?

A

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”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

To send the output from printf to a variable instead of to a browser, what alternative function would you use?

A

To send the output from printf to a variable instead of to a browser, you would use sprintf instead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you create a Unix timestamp for 7:11 am. on May 2, 2016?

A

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);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the PHP command for deleting the file file.txt?

A

The PHP command for deleting the file file.txt is: unlink(‘file.txt’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which HP function is used to read in an entire file in one go, even from across the web?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which PHP superglobal variable holds the details on uploaded files?

A

The PHP superglobal associative array $_FILES contains the details about uploaded files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which PHP function enables the running of system commands?

A

The PHP exec function enables the running of system commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following tag styles is preferred in HTML5? <hr> or <hr>?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly