3v4l.org

run code in 300+ PHP versions simultaneously
<?php const MADNESS = <<<EOM <?php yield // this comment doesn't make sense, but hey, why not? /* the blank line above doesn't make sense either, as well as this comment */ /* and thinking about it – */ // why not go batshit crazy with this? /* he */ from gen2(); EOM; $comments = token_get_all("<?php" . substr(token_get_all(MADNESS)[2][1], 5, -4)); array_shift($comments); // drop <?php var_dump($comments);
Output for 8.4.1 - 8.4.4
array(8) { [0]=> array(3) { [0]=> int(391) [1]=> string(53) "// this comment doesn't make sense, but hey, why not?" [2]=> int(1) } [1]=> array(3) { [0]=> int(396) [1]=> string(6) " " [2]=> int(1) } [2]=> array(3) { [0]=> int(391) [1]=> string(77) "/* the blank line above doesn't make sense either, as well as this comment */" [2]=> int(3) } [3]=> array(3) { [0]=> int(396) [1]=> string(6) " " [2]=> int(3) } [4]=> array(3) { [0]=> int(391) [1]=> string(31) "/* and thinking about it – */" [2]=> int(5) } [5]=> array(3) { [0]=> int(396) [1]=> string(1) " " [2]=> int(5) } [6]=> array(3) { [0]=> int(391) [1]=> string(47) "// why not go batshit crazy with this? /* he */" [2]=> int(5) } [7]=> array(3) { [0]=> int(396) [1]=> string(6) " " [2]=> int(5) } }
Output for 8.3.0, 8.3.2, 8.3.4, 8.3.7, 8.3.9, 8.3.11, 8.3.13, 8.3.15, 8.3.17
array(8) { [0]=> array(3) { [0]=> int(392) [1]=> string(53) "// this comment doesn't make sense, but hey, why not?" [2]=> int(1) } [1]=> array(3) { [0]=> int(397) [1]=> string(6) " " [2]=> int(1) } [2]=> array(3) { [0]=> int(392) [1]=> string(77) "/* the blank line above doesn't make sense either, as well as this comment */" [2]=> int(3) } [3]=> array(3) { [0]=> int(397) [1]=> string(6) " " [2]=> int(3) } [4]=> array(3) { [0]=> int(392) [1]=> string(31) "/* and thinking about it – */" [2]=> int(5) } [5]=> array(3) { [0]=> int(397) [1]=> string(1) " " [2]=> int(5) } [6]=> array(3) { [0]=> int(392) [1]=> string(47) "// why not go batshit crazy with this? /* he */" [2]=> int(5) } [7]=> array(3) { [0]=> int(397) [1]=> string(6) " " [2]=> int(5) } }
Output for 8.3.1, 8.3.3, 8.3.5 - 8.3.6, 8.3.8, 8.3.10, 8.3.12, 8.3.14, 8.3.16
array(8) { [0]=> array(3) { [0]=> int(387) [1]=> string(53) "// this comment doesn't make sense, but hey, why not?" [2]=> int(1) } [1]=> array(3) { [0]=> int(392) [1]=> string(6) " " [2]=> int(1) } [2]=> array(3) { [0]=> int(387) [1]=> string(77) "/* the blank line above doesn't make sense either, as well as this comment */" [2]=> int(3) } [3]=> array(3) { [0]=> int(392) [1]=> string(6) " " [2]=> int(3) } [4]=> array(3) { [0]=> int(387) [1]=> string(31) "/* and thinking about it – */" [2]=> int(5) } [5]=> array(3) { [0]=> int(392) [1]=> string(1) " " [2]=> int(5) } [6]=> array(3) { [0]=> int(387) [1]=> string(47) "// why not go batshit crazy with this? /* he */" [2]=> int(5) } [7]=> array(3) { [0]=> int(392) [1]=> string(6) " " [2]=> int(5) } }
Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.27
array(0) { }

preferences:
63.5 ms | 418 KiB | 5 Q