I'm a novice php and I'm stuck on a problem I was hoping someone could offer me help with.
When I upload a .php with the following contents to my server and load it in a chrome browser there doesn't seem to be any problem.
<?php
class AppInfo {
public static function getHome () {
return ($_SERVER['HTTP_X_FORWARDED_PROTO'])."://" . $_SERVER['HTTP_HOST'] . "/";
}
}
However when I upload a .php file containing the very similar code below (the difference is the presence of ?:"http"), chrome returns a server error (pasted below the code)
<?php
class AppInfo {
public static function getHome () {
return ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?: "http") . "://" . $_SERVER['HTTP_HOST'] . "/";
}
}
Error:
Server error The website encountered an error while retrieving "Url" It may be down for maintenance or configured incorrectly.
You should change it to
So this would mean that if
($_SERVER['HTTP_X_FORWARDED_PROTO']
is there use it else usehttp
.