3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function test($input) { $output = htmlspecialchars($input, ENT_QUOTES, 'UTF-8'); $code = str_replace('%', '\\x', rawurlencode($input)); if (validate_utf8($input)) { echo "【{$output}】({$code}) は有効なUTF-8シーケンスです。\n"; } else { echo "({$code}) は無効なUTF-8シーケンスです。\n"; } } test("☝( ◠‿◠ )☝"); test("ゔ〲〰"); test("\x0a\x92\xff"); // てきとー test("\xef\xbb\xbf"); // BOMだっけ test(""); // 空文字列 echo "\n"; test("\x2f"); // スラッシュ(1バイト) test("\xc0\xaf"); // スラッシュ(冗長2バイト) test("\xe0\x80\xaf"); // スラッシュ(冗長3バイト) test("\xf0\x80\x80\xaf"); // スラッシュ(冗長4バイト)
based on oXOEL

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Fatal error: Uncaught Error: Call to undefined function validate_utf8() in /in/4NNW0:8 Stack trace: #0 /in/4NNW0(16): test('\xE2\x98\x9D( \xE2\x97\xA0\xE2\x80\xBF\xE2\x97\xA0 ...') #1 {main} thrown in /in/4NNW0 on line 8
Output for Arrow functions
Fatal error: Uncaught Error: Call to undefined function validate_utf8() in /in/4NNW0:8 Stack trace: #0 /in/4NNW0(16): test('\xE2\x98\x9D( \xE2\x97\xA0\xE2\x80\xBF\xE2\x97\xA0 ...') #1 {main} thrown in /in/4NNW0 on line 8
Output for Object typehint
Fatal error: Uncaught Error: Call to undefined function validate_utf8() in /in/4NNW0:8 Stack trace: #0 /in/4NNW0(16): test('\xE2\x98\x9D( \xE2\x97\xA0\xE2\x80\xBF\xE2\x97\xA0 ...') #1 {main} thrown in /in/4NNW0 on line 8
Output for Array change keys
Fatal error: Uncaught Error: Call to undefined function validate_utf8() in /in/4NNW0:8 Stack trace: #0 /in/4NNW0(16): test('\xE2\x98\x9D( \xE2\x97\xA0\xE2\x80\xBF\xE2\x97\xA0 ...') #1 {main} thrown in /in/4NNW0 on line 8
Output for Lexical anon
Fatal error: Call to undefined function validate_utf8() in /in/4NNW0 on line 8

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page