3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a=array(); if(empty($a)) echo 'empty'; // 一个有效的 json 字符串 $json [] = '{"Organization": "PHP Documentation Team"}' ; // 一个无效的 json 字符串会导致一个语法错误,在这个例子里我们使用 ' 代替了 " 作为引号 $json [] = "{'Organization': 'PHP Documentation Team'}" ; // 无效的 UTF8 序列 $text = "\xB1\x31" ; $json = json_encode ( $text ); $error = json_last_error (); var_dump ( $json , $error === JSON_ERROR_UTF8 );
Output for 5.5.0 - 7.1.0
emptybool(false) bool(true)
Output for 5.3.3 - 5.3.13, 5.3.15 - 5.4.45
emptystring(4) "null" bool(true)
Output for 5.3.14
empty Warning: json_encode(): Invalid UTF-8 sequence in argument in /in/L8ri1 on line 13 bool(false) bool(true)
Output for 5.3.0 - 5.3.2
empty Notice: Use of undefined constant JSON_ERROR_UTF8 - assumed 'JSON_ERROR_UTF8' in /in/L8ri1 on line 16 string(4) "null" bool(false)
Output for 5.2.0 - 5.2.17
empty Fatal error: Call to undefined function json_last_error() in /in/L8ri1 on line 14
Process exited with code 255.
Output for 5.0.0 - 5.1.6
empty Fatal error: Call to undefined function json_encode() in /in/L8ri1 on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
empty Fatal error: Call to undefined function: json_encode() in /in/L8ri1 on line 13
Process exited with code 255.
Output for 4.3.2 - 4.4.4
empty Fatal error: Call to undefined function: json_encode() in /in/L8ri1 on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
empty Fatal error: Call to undefined function: json_encode() in /in/L8ri1 on line 13