nerdexam
Zend

200-550 · Question #216

Given a PHP value, which sample shows how to convert the value to JSON?

The correct answer is A. $string = json_encode($value). See the full explanation below for the reasoning.

Question

Given a PHP value, which sample shows how to convert the value to JSON?

Options

  • A$string = json_encode($value);
  • B$string = Json::encode($value);
  • C$json = new Json($value); $string = $json->__toString();
  • D$value = (object) $value; $string = $value->__toJson();

How the community answered

(36 responses)
  • A
    75% (27)
  • B
    8% (3)
  • C
    14% (5)
  • D
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 200-550 Practice