nerdexam
Zend

200-710 · Question #3

What is the output of the following code? $string = 'Good luck!'; $start = 10; var_dump(substr($string, $start, $start));

The correct answer is C. string(1) "!". See the full explanation below for the reasoning.

Strings & Patterns

Question

What is the output of the following code? $string = 'Good luck!'; $start = 10; var_dump(substr($string, $start, $start));

Options

  • Astring(0) ""
  • Bbool(false)
  • Cstring(1) "!"
  • Dstring(2) "k!"

How the community answered

(59 responses)
  • A
    15% (9)
  • B
    5% (3)
  • C
    69% (41)
  • D
    10% (6)

Topics

#substr#string indexing#edge cases#string functions

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice