Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Newbie Needs a Hand

  • 13-05-2002 11:22pm
    #1
    Registered Users, Registered Users 2 Posts: 1,783 ✭✭✭


    Hi,
    I just installed PHP so I'm a complete newbie to this. I have a problem already, I'm not sure if it's normal or not but perhaps one of ye guys can help me out.

    I'm trying out the Introductory Tutorial on PHP.net here --> http://www.php.net/tut.php and I've fallen at the second hurdle.

    I want to write the PHP script that produces the user's browser type. The tutorial at PHP.net says I should use this:
    [PHP]<?php echo $HTTP_USER_AGENT; ?>[/PHP]
    It seems to make sense but it doesn't work. I just get a blank page.

    So, in an effort to find out what the problem was, I went and made a script containing this code:
    [PHP]<?php phpinfo(); ?>[/PHP]
    This should have given me loads of info about PHP, which it did. I went looking for the variable $HTTP_USER_AGENT on that page but couldn't find it. Instead I found the variable $_SERVER["HTTP_USER_AGENT"] and used this in the script that I wanted to show the browser type.

    So now my script looks like this:
    [PHP]<?php echo $_SERVER["HTTP_USER_AGENT"]; ?>[/PHP]

    That did the job. But is this normal? Did they change the names of the variables and, therefor, is the tutorial I'm reading out of date or something?


Comments

  • Registered Users, Registered Users 2 Posts: 2,518 ✭✭✭Hecate


    you're not using php 4.2.0 by any chance?

    there have been quite a few changes from the last version, particularly in regard to accessing HTTP environment variables.


  • Closed Accounts Posts: 6,601 ✭✭✭Kali


    i presume you are using IIS.. it stores slightly different enviroment variables than apache.. in this case the user_agent is stored in the server_vars array.
    there should be a full list of variables in the IIS documentation..


  • Registered Users, Registered Users 2 Posts: 1,783 ✭✭✭Puck


    I'm using PHP 4.2.0 and Apache 1.3.24 on Win XP.


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    What Hecate said Puck. For security reasons, the developers have turned off automatic environment generation in the global environment and moved them into pseudo globals prefixed with _ instead. You can adjust the behaviour back to the old way, but as a new developer you're better off this way.

    adam


  • Registered Users, Registered Users 2 Posts: 1,783 ✭✭✭Puck


    Grand! That's me sorted so! :D
    Was just wondering if it was normal.
    Thanks everyone!:)


  • Advertisement
Advertisement