3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php //> Will count number of <[a-z]> tag and </[a-z]> tag (will also validate the order) //> Note br should be in the form of <br /> for not causing problems function validHTML($html,$checkOrder=true) { preg_match_all( '#<([a-z]+)>#i' , $html, $start, PREG_OFFSET_CAPTURE ); preg_match_all( '#<\/([a-z]+)>#i' , $html, $end, PREG_OFFSET_CAPTURE ); $start = $start[1]; $end = $end[1]; if (count($start) != count($end) ) throw new Exception('Check numbers of tags'); if ($checkOrder) { $is = 0; foreach($end as $v){ if ($v[0] != $start[$is][0] || $v[1] < $start[$is][1] ) throw new Exception('End tag ['.$v[0].'] not opened'); $is++; } } return true; } //> Usage:: try { validHTML('<p>hello</p><li></li></p><p>'); } catch (Exception $e) { echo $e->getMessage(); }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.10.0130.06020.09
7.0.00.0030.04020.22
5.6.160.0070.05320.46
5.6.150.0000.05718.14
5.6.140.0000.04718.19
5.6.130.0030.04018.19
5.6.120.0070.08320.96
5.6.110.0070.08021.00
5.6.100.0100.06720.98
5.6.90.0170.06320.98
5.6.80.0070.08320.35
5.5.300.0030.05017.95
5.5.290.0030.08317.98
5.5.280.0130.07320.87
5.5.270.0000.04720.75
5.5.260.0100.06320.76
5.5.250.0100.06020.61
5.5.240.0100.08020.11

preferences:
138.82 ms | 1394 KiB | 7 Q