PHP exam question- superglobals

I have a PHP exam on Friday and a question is bound to come up about superglobals. I have absolutely no idea about programming,and when I look for the answers on the Internet I get incredibly confused. The question asks you to describe the purpose and state when it would be appropriate to use them developing a PHP program. The superglobals are

$_REQUEST
$_COOKIES
$_FILES
$_SESSION

If anybody could help with simple answers Id be very appreciative! Thank you

Katie

So…you have an exam, and yet you haven’t gone to the lessons/studied for it. You’re cramming last-minute information, and let me tell you: superglobals have a lot more scope than you think. You won’t be able to ace it.

Anyway. The info you are looking for is at http://php.net/manual/en/language.variables.superglobals.php. In a nutshell:

  • $_REQUEST is a mix of all the GET and POST parameters passed to your script, with POST parameters overriding GET parameters
  • $_COOKIES contains the client’s cookies in a key=>value format
  • $_FILES contains the information (name, temp name, size, type) sent by the client in a multipart/form-data request
  • $_SESSION contains variables stored in an user’s session

Their usage should be obvious. Where they are waiting for you is their usage… and for this, the best way to learn is to read the doc and to read around. It’s your exam - how bad would it look if you aced it and subsequently failed to answer it at a subsequent interview/quizz/test?

Sponsor our Newsletter | Privacy Policy | Terms of Service