Parse error: syntax error, unexpected T_STRING

Reading the “important” posts at the top of this PHP forum, I can tell that there is supposed to be a missing quote, or parentheses on line four or five, but I can’t simply figure out where.

Some help is appreciated.

The error, I get is: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\mydomain\logs.php on line 5

<?php
// Getting the information
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page = "http\\://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
$page .= iif(!empty($_SERVER['QUERY_STRING']), '?($_SERVER['QUERY_STRING'])',"");
$referrer = $_SERVER['HTTP_REFERER'];
$datetime = mktime();
$useragent = $_SERVER['HTTP_USER_AGENT'];
$remotehost = @getHostByAddr($ipaddress);
// Create log line
$logline = $ipaddress . "|" . $referrer . "|" . $datetime . "|" . $useragent . "|" . $remotehost . "|" . $page . "\
";

// Write to log file:
$logfile = "c:/wamp/www/mydomain/logfile.txt";

// Open the log file in “Append” mode
if (!$handle = fopen($logfile, 'a+')) {
die("Failed to open log file");
}

// Write $logline to our logfile.
if (fwrite($handle, $logline) === FALSE) {
die("Failed to write to log file");
}

fclose($handle);
?>

Thanks in advance.


$page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}","");

$page .= iif(!empty($_SERVER['QUERY_STRING']), '?($_SERVER['QUERY_STRING'])',"");

What in the world are you doing here?

I didn’t want to be the one to pass judgement but since it was brought up and all…

The iif function looks to me like an abstraction of the ternary operator. If so I can’t say I would agree with having a function for that…