3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* IMPORT SPORTS CATEGORIES */ echo "import categories for lang=$lang\n"; $url = "https://www.bet3000.com/".$lang."/jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories"; try { $data = file_get_contents($url); $data = json_decode($data, true); $query = "UPDATE home_categories SET active=0"; if (!$debug) { mysql_query($query); } $cat_lvl_ids[0] = array("id" => 0,"label" => ""); $prev_lvl = 0; $parent_id = 0; $index = 0; $flag = false; $sortid=0; foreach ($data ['categories'] as $key => $value){ $sortid++; $cat = new Category($value); $lvl = $cat->get_level(); $id = $cat->get_id(); $active = $cat->get_activated_id(); $cat_lvl_ids[$lvl]["id"] = $id; $parent_id = $cat_lvl_ids[$lvl-1]["id"]; $parent_lbl = ""; if(!empty($cat_lvl_ids[$lvl-1]["label"])) { $parent_lbl = $cat_lvl_ids[$lvl-1]["label"]." / "; } $path = $parent_lbl . $cat->get_label(); $cat_lvl_ids[$lvl]["label"] = $path; $explode = explode(" / ",$path); $detail = $explode[count($explode)-1]; $sport = $explode[0]; $qcheck="SELECT * FROM `home_categories` WHERE cid=".$id." AND lang='".$lang."'"; $rcheck=mysql_query($qcheck); if (mysql_num_rows($rcheck)>0) { $ocheck=mysql_fetch_object($rcheck); $sqladd =""; $sqladd.= ",path='".trim(mysql_real_escape_string($path))."', detail='".trim(mysql_real_escape_string($detail))."'"; // UPDATE path,detail,sortid,active $querynew="UPDATE home_categories SET active=".$active.",sortid=".$sortid.$sqladd." WHERE cid=".$id." AND lang='".$lang."'"; mysql_query($querynew); echo mysql_error(); } else { $sqlheaderadd=""; $sqladd =""; $query = "INSERT IGNORE INTO `home_categories` (cid,lang,detail,path,topcatid,stufe,sport,sortid,active) VALUES (". $id.", ". "'".$lang."', ". "'".trim(mysql_real_escape_string($detail))."', ". "'".trim(mysql_real_escape_string($path))."', ". $parent_id.", ". $lvl.", ". "'".trim(mysql_real_escape_string($sport))."', ". $sortid.", ". $active. ")"; $resultInsert = mysql_query($query); if(!$resultInsert) echo mysql_error()."<br>$query"; } $prev_lvl = $lvl; } //foreach($result as $v) { // echo $value."<br>"; //} } catch(Exception $e) { echo $e->getMessage(); } echo 'Categories added to database'; class Category { private $id; private $lvl; private $label; private $activated_id; private $children; public function __construct($cat) { $this->id = $cat['id']; $this->lvl = $cat['level']; $this->label = $cat['label']; $this->activated_id = $cat['activated_id']; $this->children = array(); } public function get_id() { return $this->id; } public function get_level() { return $this->lvl; } public function get_label() { return $this->label; } public function get_activated_id() { return $this->activated_id; } public function get_children() { return $this->children; } public function set_id($id) { $this->id = $id; } public function set_level($lvl) { $this->lvl = $lvl; } public function set_label($label) { $this->label = $label; } public function set_children($children) { $this->children = $children; } public function add_child($child) { $this->children[] = $child; } public function get_child($index) { return $this->children[$index]; } public function remove_child($child,$index) { $this->children[] = null; } public function __toString() { return "Category Lvl:".$this->get_level()." - ".$this->get_id(). ":".$this->get_label(); } }
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: Undefined variable $lang in /in/gg4li on line 5 import categories for lang= Warning: Undefined variable $lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories) is not within the allowed path(s): (/tmp:/in:/etc) in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): Failed to open stream: Operation not permitted in /in/gg4li on line 8 Warning: Undefined variable $debug in /in/gg4li on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/gg4li:12 Stack trace: #0 {main} thrown in /in/gg4li on line 12
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: Undefined variable $lang in /in/gg4li on line 5 import categories for lang= Warning: Undefined variable $lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories) is not within the allowed path(s): (/tmp:/in:/etc) in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): Failed to open stream: Operation not permitted in /in/gg4li on line 8 Warning: Undefined variable $debug in /in/gg4li on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/gg4li:12 Stack trace: #0 {main} thrown in /in/gg4li on line 12
Process exited with code 255.
Output for 8.0.13
Warning: Undefined variable $lang in /in/gg4li on line 5 import categories for lang= Warning: Undefined variable $lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): Failed to open stream: No such file or directory in /in/gg4li on line 8 Warning: Undefined variable $debug in /in/gg4li on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/gg4li:12 Stack trace: #0 {main} thrown in /in/gg4li on line 12
Process exited with code 255.
Output for 7.4.33
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: No such file or directory in /in/gg4li on line 8 Notice: Undefined variable: debug in /in/gg4li on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/gg4li:12 Stack trace: #0 {main} thrown in /in/gg4li on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories) is not within the allowed path(s): (/tmp:/in:/etc) in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: Operation not permitted in /in/gg4li on line 8 Notice: Undefined variable: debug in /in/gg4li on line 12 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/gg4li:12 Stack trace: #0 {main} thrown in /in/gg4li on line 12
Process exited with code 255.
Output for 7.3.32 - 7.3.33
import categories for lang= Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: No such file or directory in /in/gg4li on line 8 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/gg4li:12 Stack trace: #0 {main} thrown in /in/gg4li on line 12
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(): open_basedir restriction in effect. File(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories) is not within the allowed path(s): (/tmp:/in:/etc) in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: Operation not permitted in /in/gg4li on line 8 Notice: Undefined variable: debug in /in/gg4li on line 12 Fatal error: Call to undefined function mysql_query() in /in/gg4li on line 12
Process exited with code 255.
Output for 5.4.15 - 5.4.45
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/gg4li on line 8 Notice: Undefined variable: debug in /in/gg4li on line 12 Fatal error: Call to undefined function mysql_query() in /in/gg4li on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.14
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: No such file or directory in /in/gg4li on line 8 Notice: Undefined variable: debug in /in/gg4li on line 12 Fatal error: Call to undefined function mysql_query() in /in/gg4li on line 12
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: No such file or directory in /in/gg4li on line 8 Notice: Undefined variable: debug in /in/gg4li on line 12 Fatal error: Call to undefined function mysql_query() in /in/gg4li on line 12
Process exited with code 255.
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: No such file or directory in /in/gg4li on line 8 Fatal error: Call to undefined function json_decode() in /in/gg4li on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: lang in /in/gg4li on line 5 import categories for lang= Notice: Undefined variable: lang in /in/gg4li on line 6 Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/gg4li on line 8 Warning: file_get_contents(https://www.bet3000.com//jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories): failed to open stream: No such file or directory in /in/gg4li on line 8 Fatal error: Call to undefined function json_decode() in /in/gg4li on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/gg4li on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected '{' in /in/gg4li on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/gg4li on line 7
Process exited with code 255.

preferences:
294.66 ms | 401 KiB | 458 Q