3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ob_start(); ?> flarg blarg dlarg <!-- BEGIN DYNAMIC BLOCK: guide_greeting --> filler content <!-- END DYNAMIC BLOCK: guide_greeting --> flarg blarg dlarg <?php $content = ob_get_clean(); function getDyanmicBlockContent($content, $tag) { $boundaries = (object) [ 'start' => sprintf('<!-- BEGIN DYNAMIC BLOCK: %s -->', $tag), 'end' => sprintf('<!-- END DYNAMIC BLOCK: %s -->', $tag), ]; $results = (object) [ 'start' => stripos($content, $boundaries->start), 'end' => stripos($content, $boundaries->end), ]; if ($results->start === false || $results->end === false || $results->start > $results->end) { return null; } $substr = substr($content, 0, $boundaries->end); return $substr; } var_dump( getDyanmicBlockContent($content, 'guide_greeting') );
based on kgEuo
Output for 7.3.0alpha1 - 7.3.0beta1
Warning: substr() expects parameter 3 to be int, string given in /in/HTRhO on line 28 NULL
Output for hhvm-3.18.5 - 3.21.3, 7.0.30 - 7.2.7
Warning: substr() expects parameter 3 to be integer, string given in /in/HTRhO on line 28 NULL
Output for hhvm-3.22.0
Warning: substr() expects parameter 3 to be integer, string given in /in/HTRhO on line -1 NULL
Output for 5.6.30
Warning: substr() expects parameter 3 to be long, string given in /in/HTRhO on line 28 NULL