PHP Strings - Part 2 - Multiple Choice Questions

PHP Strings - Part 2 - Multiple Choice Questions

1. In PHP, the difference between double quote and single quote is that variables . . . . in single quoted strings whereas they . . . . . in double quoted strings.

A) are not parsed, are parsed
B) are parsed, are not parsed

2. PHP strings are binary-safe (i.e. they can contain null bytes) . Their size is limited only by the amount of memory that is available to PHP.

A) True
B) False

3. Print substr (‘watch out for that tree’,20,5);
What is the output of above statement?

A) tree
B) tree’
C) ree
D) none of above

$var = 'HELLO WORLD!';
$var = ucfirst($var);

What is the value of var?

A) Hello World!
B) hello world!
C) Hello world!

5. The functions strtolower() and strtoupper() work on individual characters and not on entire strings.

A) True
B) False

6. For trim, ltrim or rtrim, whitespace is defined as

A) newline
B) space
C) vertical tab
D) null
E) both a and B
F) all of above

7. Heredoc's are a great alternative to quoted strings because of increased readability and maintainability.

A) True
B) False

8. Which of the below is most useful for debugging:

A) print()
B) printf()
C) print_r()
D) echo

$name = “John”;
$message = ‘Hello, $name’;

What is the value of message?

A) Hello, John
B) it will print an error message
C) ‘Hello, $name’
D) none of above

$str = "Hello fri3nd, you're
       feeling          happy today?”;
echo str_word_count($str);

A) 7
B) 6
C) 5
D) 4