A good way to start solving your problem is by identifying where PHP is registering the User-Agent variable. User-Agent is an HTTP header and is sent to every request.
Start by making a PHP page with code:
<?php phpinfo(); ?>
This page comes with a lot of information about PHP: which version, whether it is installed on Apache server or any other and... also has the headers and in turn the User-Agent passed by the browser! Search your browser by searching with CTRL+F on the page.
Here in my example, we have the line:
PHP Variables
_SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Note that on my server, your code works! But it may be that your server is another, and then this variable may be another.
About something related, you can also make a code[1] and see all HTTP headers, including the User-Agent:
<?php
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
?>
But this only works on Apache-like servers.
[1] Source: http://php.net/manual/en/function.apache-request-headers.php
Syntax error is not in these lines.
– bfavaretto
It is the first { that this on line three I just modified here to stay together but the code is just that it has nothing else is just a test page
– Gonsales
there’s nothing wrong...
– HiHello
The interpreter can get lost in syntax errors, it can indicate a line because there it was possible to identify that there is an error but in fact the actual origin of the error may be in another line. I’ll give you a hint: if you try to be careful in the organization of your code it is much easier to understand it and find possible errors. Just because you can write everything together doesn’t mean you should. It even serves to better organize the thinking about the algorithm. The human brain works better that way.
– Maniero
But there are no other lines just these, as Avia said I just modified to get everything together here but the line 3 is found the first { I’ve researched several sites all have similar examples but it doesn’t work I don’t know if it can be problem with wamp?
– Gonsales
I doubt it is WAMP. This code is correct and does not have 3 lines, so it is impossible to have only these lines. Look at it working: http://ideone.com/FuWm2s. There’s another problem in it, but it’s for another reason.
– Maniero
Post your code exactly how it’s on your machine (I don’t know if it’s the way @Kaduamaral put it).
– bfavaretto
And review the error also if you are now presenting another message. Now it became more difficult to still have error in line 3. Anyway, piled up, the error will be in line 1, could have several, all would be in line 1 as it is in the comment. Separating code into multiple lines is not freshness, it is important to facilitate maintenance.
– Maniero
Thank you is just like that!!! really do not know why should give this error I keep searching in several forums and all are similar examples and as everyone here say that there is no error gets more difficult!!!
– Gonsales
It’s unlikely he’s exactly like this. In programs any minor detail can make a difference. Without seeing each character we have nothing to do. You will have to call some experienced programmer you know there to help you.
– Maniero