1--TEST-- 2json_encode() & endless loop - 1 3--FILE-- 4<?php 5 6$a = array(); 7$a[] = &$a; 8 9var_dump($a); 10 11echo "\n"; 12 13var_dump(json_encode($a)); 14var_dump(json_last_error(), json_last_error_msg()); 15 16echo "\n"; 17 18var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR)); 19var_dump(json_last_error(), json_last_error_msg()); 20 21echo "Done\n"; 22?> 23--EXPECTF-- 24array(1) { 25 [0]=> 26 *RECURSION* 27} 28 29bool(false) 30int(6) 31string(%d) "Recursion detected" 32 33string(6) "[null]" 34int(6) 35string(%d) "Recursion detected" 36Done 37