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.