I tried to assign a var with gethostname()
(1) and with $_SERVER
(2) and I keep on getting ReferenceError: gethostname is not defined
.
All I want is to get the current system name into a var using JS which runs in my PHP. What am I doing wrong?
UPDATE:
var myVar = gethostname();
or
var myVar = $_SERVER;
So, I approached this whole issue a little differently, and my initially approach was wrong to begin with.
I decided to get the IP address by executing
$ipAddress = getenv("REMOTE_ADDR");
Then I wanted to get the host name, so I did a shell execution:
$myArg = "nslookup $ipAddress";
Eventually I used stripos
to get the start ("name = ") and end ("domain.name") positions of the host name, and eventually I used substr
to get the hostname out.
I will use the result to pass it to the JS.