I'm using the following code to try and print the operating system of the user:
Header:
<?php
$user_agent = getenv("HTTP_USER_AGENT");
if (strpos($user_agent, "Win") !== FALSE)
$os = "Windows";
else (strpos($user_agent, "Mac") !== FALSE)
$os = "Mac";
?>
Body:
<?php
if($os = "Windows")
{
}
elseif($os == "Mac")
{
}
?>
I get the error
Parse error: syntax error, unexpected '$os' (T_VARIABLE) in C:\xampp\xamppfile\htdocs\ProjectSite\includes\identifier.php on line 7
$user_agent
is neither Mac nor Windows? That will lead to an undefined$os
, won't it? – TRiG Mar 11 '14 at 11:27