Trying to test a method that is doing a json_encode
and throwing an exception if the encode fails. However, whatever I throw at json_encode
it successfully encodes. Any idea what would be something simple to have it fail?
I think the smallest values to fail json_encode
would be:
json_encode(NAN);
json_encode(INF);
Other candidate:
$a = array(&$a);
json_encode($a);
$text = "\xB1\x31";
$json = json_encode($text);
For checking errors you can use json_last_error().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With