
|
|
|||
Introduction to PHP ProgrammingBy PHP Catalyst2007-11-19
Variables in PHP VariablesA variable is something that is subject to variation or likely to vary. In PHP variables are represented with a dollar sign before the variable name. For example $a, $b are variables. The variable name is case-sensitive and must always start with a character. So, $a and $A are different variable names. Some examples are:
<?phpPredefined variablesPHP provides significant number of predefined variables, some of which are platform dependent, version specific, server specific. Some of the widely used predefined variables are: Server variables:$_SERVER when used, offers information such as hostname, script name, location etc. When used, the information is obtained onto this array from the web server running PHP. However, as we read before, you may not be able to get all the information when this variable is used. Widely used elements of $_SERVER are as mentioned below: 'PHP_SELF' refers to file name of the currently executed script. For instance if the URL is http://www.phpcatayst.com/examples/self.php then $_SERVER['PHP_SELF'] will refer to /examples/self.php 'argv' array of arguments passed to the script. contains the number of command line parameters passed to the script 'SERVER_ADDR' the IP address of the server on which the current script is executing. 'SERVER_NAME' the hostname of the server on which the current script is executing. 'REQUEST_METHOD' request method which was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'. 'QUERY_STRING' the query string, via which the page was accessed. 'DOCUMENT_ROOT' the document root directory under which the current script is executing. This information is obtained from server's configuration file. 'HTTP_ACCEPT' contents of the Accept: header from the current request, if there is one. 'HTTP_REFERER' the address of the page which referred to the current page. 'HTTPS' set to a non-empty value if the script was queried through the HTTPS protocol. 'REMOTE_ADDR' the IP address from which the user is viewing the current page. 'REQUEST_URI' the URI used to access the current page. Tutorial Pages: » What can I do with PHP? » Popoular Features of PHP » Basics of PHP » Variables in PHP » Data Types in PHP » Expressions and Operators » Control Structures in PHP » Functions in PHP » Declaring Functions in PHP » Scope of a Variable » Built-in Functions in PHP » Handling Strings in PHP » Printing Strings in PHP » String Comparisons in PHP » Manipulating Strings in PHP » Arrays in PHP » Types of Arrays in PHP » Creating Arrays in PHP » Array Operations in PHP |
||||
| About the NetVisits, Inc Network | Write For Us | Advertise Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy. |
Visit other NetVisits, Inc. sites: |