Hello,
I have the following code below that has been working fine on PHP 5.4, but when ran on PHP 5.6 if just breaks and prints out the code to the page instead of running it. I’ve been looking around online but can’t find anything to suggest why it has been happening.
It seems to break at every => or -> in this single file. In every other file where there’s a -> or => it works totally fine.
[php]
function countryCityFromIP($ipAddr)
{
if ($ipAddr == “0.0.0.0”) {
return null;
}
$country = ip_details($ipAddr);
$country = strtolower($country);
$image = “…/images/icons/{$country}.png”;
return $image;
}
function ip_details($ip) {
$newIp = explode(":", $ip);
$ip = $newIp[0];
$json = file_get_contents(“http://ipinfo.io/{$ip}/json”);
$details = json_decode($json);
return $details->country;
}
function getSteamDetails($steamid) {
$_STEAMAPI = $_SESSION[“apikey”];
$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=" . toCommunityID($steamid);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json_decoded = json_decode(curl_exec($ch));
return $json_decoded->response->players[0];
}
function getVacBans($steamid) {
$_STEAMAPI = $_SESSION[“apikey”];
$url = "http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=$_STEAMAPI&steamids=" . toCommunityID($steamid);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json_decoded = json_decode(curl_exec($ch));
return $json_decoded->players[0];
}
[/php]
When every the code runs a -> it just prints out all the code after the -> as shown in the code below (Can’t add picture in to show it). It prints out all the code from line 20 and below.
Output:
country; } function getSteamDetails($steamid) { $_STEAMAPI = $_SESSION[“apikey”]; $url = “http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=” . toCommunityID($steamid); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $json_decoded = json_decode(curl_exec($ch)); return $json_decoded->response->players[0]; } function getVacBans($steamid) { $_STEAMAPI = $_SESSION[“apikey”]; $url = “http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=$_STEAMAPI&steamids=” . toCommunityID($steamid); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $json_decoded = json_decode(curl_exec($ch)); return $json_decoded->players[0]; } ?>
Any help would be greatly appreciated on understanding on why this works in PHP 5.4 and not PHP 5.6.