Skip to Content
PHP Pocket Reference
book

PHP Pocket Reference

by Rasmus Lerdorf
January 2000
Beginner to intermediate
128 pages
1h 48m
English
O'Reilly Media, Inc.
Content preview from PHP Pocket Reference

Web-Related Variables

PHP automatically creates global variables for all the data it receives in an HTTP request. This can include GET data, POST data, cookie data, and environment variables. Say you have an HTML form that looks as follows:

<FORM ACTION="test.php3" METHOD="POST">
<INPUT TYPE=text NAME=var>
</FORM>

When the form is submitted to the test.php3 file, the $var variable within that file is set to whatever the user entered in the text field.

A variable can also be set in a URL like this:

http://your.server/test.php3?var=Hello+World

When the request for this URL is processed, the $var variable is set for the test.php3 page.

Any environment variables present in your web server’s configuration are also made available, along with any CGI-style variables your web server might set. The actual set of variables varies between different web servers. The best way to get a list of these variables is to use PHP’s special information tag. Put the following code in a page and load the page in your browser:

<? phpinfo(  ) ?>

You should see a page with quite a bit of information about PHP and the machine it is running on. There is a table that describes each of the extensions currently enabled in PHP. Another table shows the current values of all the various configuration directives from your php3.ini file. Following those two tables are more tables showing the regular environment variables, the special PHP internal variables, and the special environment variables that your web server has ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

PHP Pocket Reference, 2nd Edition

PHP Pocket Reference, 2nd Edition

Rasmus Lerdorf
PHP 7: Real World Application Development

PHP 7: Real World Application Development

Doug Bierer, Altaf Hussain, Branko Ajzele

Publisher Resources

ISBN: 1565927699Catalog PageErrata