Know about variable related with server

php-variables

The server which is hosting your site (we can suppose on this short training you’ve a merchant account with an ISP, therefore a person controlling the particular server) may well offer you a lots of helpful data. Within the next table we all employ a straightforward rule that can let people to acquire a lot of data from your server.

serverinfo.php
<form method=post action=serverinfo.php?a=1&b=2&c=3>Name: <input type=text name=name><br>Age: <input type=text name=age><br><input type=submit value=submit></form>
<hr><?phpprint phpinfo ();?>

 

As soon as viewing this page you will find an application within the prime a great a huge amount of information bellow, yet to acheive a lot more information, complete the form and submit the item.  Then all of us look for the result web page.

Inside result web page you will get the actual variation installed within your server and additional information regarding the actual personal computer and precisely how it’s been setup to back up.

Additionally, and we will target this specific section of the information supplied, in the last section of the result web page all of us will find the part upon variables. According to the version installed within the server, we may find slightly different files for the reason that stand. We complete think producing this specific result web page is extremely helpful, therefore all of us recommend therefore. �

We’ve got draw out one of the lines from the variables obtained from in which portion of the actual result web page to indicate anyone the best way to work with it.

PHP_SELF /mydir/serverinfo.php

So we now have the changing and linked worth (in this circumstance the comparative way to the page). �

Make it possible for suppose you should demonstrate in our webpage which details. For example inside the webpage “askyourserver. php” preceding, we want the actions in our variety for being came into automatically, so that it works accurately such as which has a unique document brand (file1. php, file2. php, and many others. ). So you should have this:

 

<form method=post action=”relative path to our script“>

 

We realize PHP_SELF variable can provide us of which info, and so most of us could make a tiny transformation in the variable name via PHP_SELF to $PHP_SELF, and we will applied this second item just one in your web page as in this case bellow:

 

pagename.php (you may change the name of the file)
<form method=get action=<?php print $PHP_SELF; ?>>Name: <input type=text name=name><br>Age: <input type=text name=age><br><input type=submit value=submit></form>
<hr>Hi <?php print $_GET[“name”]; ?>,I know you are  <?php print $_GET[“age”]; ?> years old.

 

So inside response page the contour can position here we are at identical web page. Moreover, in this reaction web page we’ve incorporating two limitations that is accustomed to add the data joined inside kind from the reaction web page. To find out more with regards to answering and adjusting kinds you might head over to these pages.

Depending on the model fitted within the server organic beef applied $_GET[“name”] or perhaps $HTTP_GET_VARS[“name”] (in more mature variants ). Regardless, the results is definitely the similar (just utilize that one you will find inside set of PHP issues from “askyourserver. php” above).

Selected variables

Following Listed some of variables mostly used by intermediate level of programmers.

 

getphpvariables.php
<form method=post action=<?php print $PHP_SELF; ?>?a=1&b=2&c=3>Name: <input type=text name=name><br>Age: <input type=text name=age><br><input type=submit value=submit><br></form>Please fill the form and submit it.

<hr>

Lets get some info:

<p>PHP_SELF: <?php print $PHP_SELF; ?>

<p>The value of variable “a” (get method): <?php print $_GET[“a”]; ?>

<p>Value of variable “b” (get method): <?php print $_GET[“b”]; ?>

<p>Value of variable “c” (get method): <?php print $_GET[“c”]; ?>

<p>Value of variable “name” (post method): <?php print $_POST[“name”]; ?>

<p>Value of variable “age” (post method): <?php print $_POST[“age”]; ?>

<p>Language(s) selected in the browser: <?php print $HTTP_ACCEPT_LANGUAGE; ?>

<p>Host: <?php print $HTTP_HOST; ?>

<p>Referer: <?php print $HTTP_REFERER; ?>

<p>Browser of the visitor: <?php print $HTTP_USER_AGENT; ?>

<p>Path to our file: <?php print $PATH_INFO; ?>

<p>Query string: <?php print $QUERY_STRING; ?>

<p>Remote address: <?php print $REMOTE_ADDR; ?>

<p>Remote host: <?php print $REMOTE_HOST; ?>

<p>Name of script: <?php print $SCRIPT_NAME; ?>

<p>Name of server: <?php print $SERVER_NAME; ?>

<p>Local address: <?php print $LOCAL_ADDR; ?>

<p>Path: <?php print $PATH_TRANSLATED; ?>

You can obtaine the data in different ways as shown below

<?php print $QUERY_STRING; ?>

<?php print $_SERVER[“QUERY_STRING“]; ?>

Online Web Development Training,Video Tutorials