3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "<h1>Hello, PHP!</h1>"; $file = fopen("input.txt","r"); $list = new SplDoublyLinkedList(); //$list = new LinkList(); while(! feof($file)) { //print_r(fgetcsv($file)); $list->push(fgets($file)); //print_r(fgets($file)); } fclose($file); $list->rewind(); $currCityP = str_getcsv($list->current()); $string=implode(",",$currCityP); //echo "Init CurrCityP".$string."\r\n<br>"; $nextCityP = str_getcsv($list->current()); $string=implode(",",$nextCityP); //echo "Init nextCityP".$string."\r\n<br>"; //echo "Total num of cities is: ".$list->count()."\r\n<br>"; for ($x=1; $x<=$list->count(); $x++) { $currCityP = $nextCityP; $y=1; $min=10000; for ($list->rewind(); $list->valid(); $list->next()) { $tmpCityP = str_getcsv($list->current()); if ($y == $x+1) { $nextCityP = $tmpCityP; //echo "x & y are: ".$x.", ".$y."\r\n<br>"; } $y++; $dist = sqrt(pow(($tmpCityP[0]-$currCityP[0]),2)+pow(($tmpCityP[1]-$currCityP[1]),2)); if ($min > $dist && $dist != 0) { $min = $dist; } //echo "Distane".$dist."\r\n"; //echo "next\r\n"; } $string=implode(",",$currCityP); //echo "CurrCityP is: ".$string."\r\n<br>"; $string=implode(",",$nextCityP); //echo "NextCityP is: ".$string."\r\n<br>"; echo $min."\r\n<br>"; }
Output for git.master, git.master_jit
<h1>Hello, PHP!</h1> Warning: fopen(): open_basedir restriction in effect. File(input.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/nFcAa on line 3 Warning: fopen(input.txt): Failed to open stream: Operation not permitted in /in/nFcAa on line 3 Fatal error: Uncaught TypeError: feof(): Argument #1 ($stream) must be of type resource, bool given in /in/nFcAa:6 Stack trace: #0 /in/nFcAa(6): feof(false) #1 {main} thrown in /in/nFcAa on line 6
Process exited with code 255.
Output for rfc.property-hooks
<h1>Hello, PHP!</h1> Warning: fopen(): open_basedir restriction in effect. File(input.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/nFcAa on line 3 Warning: fopen(input.txt): Failed to open stream: Operation not permitted in /in/nFcAa on line 3 Fatal error: Uncaught TypeError: feof(): Argument #1 ($stream) must be of type resource, false given in /in/nFcAa:6 Stack trace: #0 /in/nFcAa(6): feof(false) #1 {main} thrown in /in/nFcAa on line 6
Process exited with code 255.

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:
29.99 ms | 401 KiB | 8 Q