PHP-Http Environment Variables



A Web browser makes a request of a Web server, it sends along with
 the request a list of extra variables. These are called environment
 variables, and they can be very useful for displaying dynamic
content or authorizing users.

The phpinfo function displays a wealth of information about your Web
 server software and the version of PHP you are running, in addition
to the basic HTTP environment.



<?php  phpinfo(); ?>



Save the file with the name phpinfo.php and place this file in the
document root of your Web server.

Open your Web browser and type http://127.0.0.1/phpinfo.php


Retrieving and Using REMOTE_ADDR
By default, environment variables are available to PHP scripts
as $VAR_NAME. For example, the REMOTE_ADDR environment variable is
already contained as $REMOTE_ADDR. However, to be absolutely sure
that you're reading the correct value, use the getenv function
to assign a value to a variable of your choice.

The REMOTE_ADDR environment variable contains the IP address of the
 machine making the request. Let's get the value of your REMOTE_ADDR.

Open a new file in your text editor.

Open a PHP block, then use getenv to place the value of REMOTE_ADDR
 in a variable called $address:

<?
$address = getenv("REMOTE_ADDR");

//Print the value of $address to the screen.

echo "Your IP address is $address.";
?>

Save the file with the name testaddress.php, then place this file in the
 document root of your Web server.

Open your Web browser and type http://127.0.0.1/testaddress.php



PHP-HTTP_USER_AGENT
<?
$agent = getenv("HTTP_USER_AGENT");

Print the value of $agent to the screen,

echo " You are using $agent.";
?>


 HTTP Headers

An HTTP - HyperText Transfer Protocol header is used to send information
 back and forth between the server and the client the Web browser.
 Normally this information is in the form of HTML, which is why
the address for Web pages begins with http://.

To redirect the user's browser with PHP, the code:

header("Location: page.php");

You can also use the header function to send cookies, which is a
good backup to the setcookie function which sometimes has
inconsistent results from one browser to the next.

But HTTP headers are a complicated enough subject to warrant a little more
attention. There are actually dozens upon dozens of uses for HTTP headers,
 all of which you can take advantage of using PHP's header function.

PHP Functions
Php tutorial - imagemagick
php.ini Basics
PHP Sessions
Cookies Versus Sessions
PHP Web-Related Variables
PHP ERRORS
maximum size of a file uploaded
Php Image upload
php file_get_contents
MySQL Data on the Web
What are GET and POST
php and pdf
$_ENV and $_SERVER
PEAR with php
SELECTING DATA PHP
prevent hijacking with PHP
LAMP
PHP MySQL Functions
PHP Zip File Functions
Substrings PHP
PHP Variable names
PHP magic methods
How to get current session id
Add variables into a session
$_GET , $_POST,$_COOKIE
different tables present in mysql
PHP CURL
php Sessions page
PHP-sorting an array
PHP-count the elements of array
Operators for If/Else Statements
PHP file uploading code
PHP global variables
Testing working using phpinfo
PHP Code for a Valid Number
PHP-Associative Arrays
PHP mvc tutorial
PHP get_meta_tags-Extracts
difference between print and echo
PHP best tutorial-PHP variables
Reading DOC file in PHP
PHP interview questions
convert time PHP
PHP implode array elements
header function-PHP
PHP-Renaming Files Directories
PHP Classes
in_array function in PHP
keep your session secure PHP
Web Application with PHP
What is SQL Injection
PHP-extract part of a string
PHP urlencode
PHP- know browser properties
PHP- Extracting Substrings
Checking Variable Values /Types
PHP-best 20 Open Source cms
IP AddressPHP
PHP-Scope Resolution Operator
how create new instance of object
how eliminate an object
PHP- ob_start
XML file using the DOM API
PHP- MVC
PHP- CAPTCHA
PHP- Position of a Value in an Array
PHP-Mail Functions
PHP-difference include vs require
calculate the sum of values in an array
PHP-total number of rows
Show unique records mysql
MySQL Triggers
MySQL data directory
MySQL Subqueries
PHP- Networking Functions
PHP- Operators
Restore database
Conditional Functions mysql
PHP-function overloading
Friend function
mysql_connect /mysql_pconnect
PHP-Error Control Operators
what is IMAP
Apache-Specific Functions
Send Email from a PHP Script
SQL inherently
WAMP, MAMP, LAMP
Php tutorial-SYMBOLS
Table Types-MySQL
PHP-Encryption data management
PHP Array
Running MySQL on Windows
Maximum Performance MySQL
XML-RPC
PHP-static variables
Advanced Database Techniques
FTP
Codeigniter
Apache Pool Size
Why NoSQL
MySQL Server Performance
Database software
SQL Interview Answers
PHP Redirect
PHP Interview Questions with Answers
Advanced PHP
Related Posts:
  • what is IMAP IMAP, fully documented in RFC 3501, was designed to provide a robust, mobile mail delivery and access mechanism. For more detail on the protocol and how it functions on the network layer, or for additional information on… Read More
  • Magic Methods-Php Php Mail Php Array Php If else Php Variable This is a link Php Substrings Php Sessions Magic Methods and Constants Magicmethods are specially named methods that can be defi nedin any class and … Read More
  • Php Code for a Valid Number Php Mail Php Array Php If else Php Variable This is a link Php Substrings Php Sessions Php Code for a Valid Number Besides working on numbers, is_numeric( ) can also be applied to numeric strings.… Read More
  • mysql_query-executes query mysql_query function  executes query on the default database, set using mysql_select_db() or by a previous query using mysql_db_query(), on the MySQL server connection referenced by connection . If no connection … Read More
  • Php for-web developers   PHP MySQL Functions Free Hosting Requiring Cookies Web Application with PHP php -Mail Functions PHP Array Substrings PHP Comparison Operators for If/Else Statements Showing the Browser and I… Read More
  • Php Form Example Since you'll need a place for the user to enter a search query, let's begin by building a form to handle the user's input. Every form must have these basic components:The submission type defined with the method keywordOne… Read More
  • Sends a message via mail function in PHP mail function allows you to send email directly from a PHP script. recipient can be  either a single email address or a comma-delimited list of addresses.  If you want to set extra headers—for instance, in order … Read More
  • PHP's variable-related functions PHP's variable-related functions are a key part of the language. Skilled programmers rely on them extensively to build robust code that uses type-checking. Functions like var_dump() and print_r() are also invaluable w… Read More
  • Php file uploading code Php Mail Php Array Php If else Php Variable This is a link Php Substrings Php Sessions Php file uploading code To uploading a file, two changes must be made to the standard HTML form. First, the… Read More
  • Advanced PHP PHP's strength lies in its huge library of built-in functions, which allows even a novice user  to perform very complicated tasks without having to install new libraries or worry about low-level details, as is often th… Read More
  • Abstract data type In programming, a data set defined by the programmer in terms of the information it can contain and the operations that can be performed with it. An abstract data type is more generalized than a data type constr… Read More
  • Php global variables Php Mail Php Array Php If else Php Variable This is a link Php Substrings Php Sessions Php global variables variables are automagically available in all contexts in function and global scopes. T… Read More
  • Learn PhP By Code PHP - Echo example            <?php              $myString = "Hi! This is a test";         … Read More
  • PHP mail function  sendmail cofiguration in php.ini file  If the smtp server you're trying to relay the    email to requires you to authenticate mail() will fail. <?php // ---------------- SEND MAIL FORM -------------… Read More
  • Php-Associative Arrays Arrays are another basic structure in programming languages. Arrays provide means for storing a fixed set (or collection) of the same datatype in a convenient way, making each element of your set indexable by using a uniqu… Read More