Coding Class

Quizgum : environment variables

Environment variables

This tutorial explains environment variables.
So let's start the lesson.
Variables in PHP have variables coming from outside of the variables we create and use.
In particular, there are many variables associated with the system. These variables are called environment variables.
You can use the phpinfo() function to view many environment variables, which contain information about the system.




php image


php image

The functions apache, session, php etc. are listed.
When using environment variables, they should be written in capital letters.
Learn about frequently used environment variables

Environment variables attribute value


Server Name


Server Protocol


Server Port


Client's IP Address


Absolute path of running file


Name of the file being run


Name of the currently running program
(php related environment variables)

So let's finish this lesson by testing the above functions.
Enter the source as shown below.


    echo "Common Environment Variable Example <br>";

    echo "1. the Name of Server : ".$_SERVER['SERVER_NAME']." <br>";
    echo "2. the Protocol of Server : ".$_SERVER['SERVER_PROTOCOL']." <br>";
    echo "3. the Port Number of Server : ".$_SERVER['SERVER_PORT']." <br>";
    echo "4. the Client's IP Address : ".$_SERVER['REMOTE_ADDR']." <br>";
    echo "5. the path of This File : ".$_SERVER['SCRIPT_FILENAME']." <br>";
    echo "6. the name of file : ".$_SERVER['SCRIPT_NAME']." <br>";
    echo "7. the name of This Program : ".$_SERVER['PHP_SELF']." <br>";


php image


php image