1--TEST-- 2An error is thrown when INF or NaN are encoded 3--FILE-- 4<?php 5 6$inf = INF; 7 8var_dump($inf); 9 10var_dump(json_encode($inf)); 11var_dump(json_last_error(), json_last_error_msg()); 12 13var_dump(json_encode($inf, JSON_PARTIAL_OUTPUT_ON_ERROR)); 14var_dump(json_last_error(), json_last_error_msg()); 15 16echo "\n"; 17 18$nan = NAN; 19 20var_dump($nan); 21 22var_dump(json_encode($nan)); 23var_dump(json_last_error(), json_last_error_msg()); 24 25var_dump(json_encode($nan, JSON_PARTIAL_OUTPUT_ON_ERROR)); 26var_dump(json_last_error(), json_last_error_msg()); 27?> 28--EXPECT-- 29float(INF) 30bool(false) 31int(7) 32string(34) "Inf and NaN cannot be JSON encoded" 33string(1) "0" 34int(7) 35string(34) "Inf and NaN cannot be JSON encoded" 36 37float(NAN) 38bool(false) 39int(7) 40string(34) "Inf and NaN cannot be JSON encoded" 41string(1) "0" 42int(7) 43string(34) "Inf and NaN cannot be JSON encoded" 44