3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MLTemplate { protected function escape($string) { return htmlspecialchars($string, ENT_COMPAT, 'UTF-8', true); } public function substr($string, $start, $length = null) { return mb_substr($string, $start, $length, 'UTF-8'); } public function esc_substr($string, $start, $length = null) { $string = $this->escape($string); $string = $this->substr($string, $start, $length); // Make sure we haven't destroyed an html entity of the end of the string. $eos = substr($string, -10); $m = array(); if (preg_match('/&[#a-zA-Z0-9]+$/', $eos, $m)) { $len = strlen($m[0]); $string = $this->substr($string, 0, -$len); } return $string; } } header('Content-Type: text/plain; charset="utf-8"'); $mlt = new MLTemplate(); var_dump($mlt->esc_substr('uasdasdadot"Ellie"', 0, 27));
Output for git.master, git.master_jit, rfc.property-hooks
string(22) "uasdasdadot&quot;Ellie"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

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


preferences:
35.7 ms | 401 KiB | 8 Q