3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test{ function __construct(){ $this->page="Test<br/>Test hého"; } function text(){ echo "\n START\n"; var_dump(mb_detect_encoding($this->page)); var_dump($this->page); echo "\n 1: "; var_dump(mb_detect_encoding($this->page)); var_dump(strlen($this->page)); $temp=htmlentities($this->page, ENT_IGNORE, 'UTF-8'); echo "\n 2: "; var_dump(mb_detect_encoding($temp)); var_dump(strlen($this->page)); echo "\n 3: "; var_dump(mb_detect_encoding($this->page)); var_dump($this->page); } } $a=new Test(); $a->text(); ?>
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Creation of dynamic property Test::$page is deprecated in /in/6FLra on line 4 START string(5) "UTF-8" string(19) "Test<br/>Test hého" 1: string(5) "UTF-8" int(19) 2: string(5) "ASCII" int(19) 3: string(5) "UTF-8" string(19) "Test<br/>Test hého"
Output for 7.0.0 - 7.0.25, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27
START string(5) "UTF-8" string(19) "Test<br/>Test hého" 1: string(5) "UTF-8" int(19) 2: string(5) "ASCII" int(19) 3: string(5) "UTF-8" string(19) "Test<br/>Test hého"

preferences:
156.35 ms | 403 KiB | 176 Q