Category Archives: PHP

Indian states list in PHP array

This section contains all the state of India in the form of associative array. The associative array having state code as key and state name as value. India has twenty eight state and seven Union territory, so total 35 states are listed below in the form of associative array. I hope it will help you guys to populate in the drop downs (Select).

 
28 Indian States list


$indian_states = array (
 'AP' => 'Andhra Pradesh',
 'AR' => 'Arunachal Pradesh',
 'AS' => 'Assam',
 'BR' => 'Bihar',
 'CT' => 'Chhattisgarh',
 'GA' => 'Goa',
 'GJ' => 'Gujarat',
 'HR' => 'Haryana',
 'HP' => 'Himachal Pradesh',
 'JK' => 'Jammu & Kashmir',
 'JH' => 'Jharkhand',
 'KA' => 'Karnataka',
 'KL' => 'Kerala',
 'MP' => 'Madhya Pradesh',
 'MH' => 'Maharashtra',
 'MN' => 'Manipur',
 'ML' => 'Meghalaya',
 'MZ' => 'Mizoram',
 'NL' => 'Nagaland',
 'OR' => 'Odisha',
 'PB' => 'Punjab',
 'RJ' => 'Rajasthan',
 'SK' => 'Sikkim',
 'TN' => 'Tamil Nadu',
 'TR' => 'Tripura',
 'UK' => 'Uttarakhand',
 'UP' => 'Uttar Pradesh',
 'WB' => 'West Bengal',
);


7 Union Territory

$indian_union_territory  = array (
 'AN' => 'Andaman & Nicobar',
 'CH' => 'Chandigarh',
 'DN' => 'Dadra and Nagar Haveli',
 'DD' => 'Daman & Diu',
 'DL' => 'Delhi',
 'LD' => 'Lakshadweep',
 'PY' => 'Puducherry',
);

All Indian states

$indian_all_states  = array (
 'AP' => 'Andhra Pradesh',
 'AR' => 'Arunachal Pradesh',
 'AS' => 'Assam',
 'BR' => 'Bihar',
 'CT' => 'Chhattisgarh',
 'GA' => 'Goa',
 'GJ' => 'Gujarat',
 'HR' => 'Haryana',
 'HP' => 'Himachal Pradesh',
 'JK' => 'Jammu & Kashmir',
 'JH' => 'Jharkhand',
 'KA' => 'Karnataka',
 'KL' => 'Kerala',
 'MP' => 'Madhya Pradesh',
 'MH' => 'Maharashtra',
 'MN' => 'Manipur',
 'ML' => 'Meghalaya',
 'MZ' => 'Mizoram',
 'NL' => 'Nagaland',
 'OR' => 'Odisha',
 'PB' => 'Punjab',
 'RJ' => 'Rajasthan',
 'SK' => 'Sikkim',
 'TN' => 'Tamil Nadu',
 'TR' => 'Tripura',
 'UK' => 'Uttarakhand',
 'UP' => 'Uttar Pradesh',
 'WB' => 'West Bengal',
 'AN' => 'Andaman & Nicobar',
 'CH' => 'Chandigarh',
 'DN' => 'Dadra and Nagar Haveli',
 'DD' => 'Daman & Diu',
 'DL' => 'Delhi',
 'LD' => 'Lakshadweep',
 'PY' => 'Puducherry',
)


how to get the server details in php

$_SERVER Data

$_SERVER is a super global array that containing information such as headers, paths, and script locations etc.
php server details
By using the $_SERVER  array you can get many server information like Server IP, Document root, Server name, server software and more.  The sever super global array are created by the server varies from server to server.

 

Here is all server element


 HTTP_HOST
 HTTP_CONNECTION
 HTTP_CACHE_CONTROL
 HTTP_ACCEPT
 HTTP_UPGRADE_INSECURE_REQUESTS
 HTTP_USER_AGENT
 HTTP_DNT
 HTTP_REFERER
 HTTP_ACCEPT_ENCODING
 HTTP_ACCEPT_LANGUAGE
 HTTP_COOKIE
 PATH
 SystemRoot
 COMSPEC
 PATHEXT
 WINDIR
 SERVER_SIGNATURE
 SERVER_SOFTWARE
 SERVER_NAME
 SERVER_ADDR
 SERVER_PORT
 REMOTE_ADDR
 DOCUMENT_ROOT
 REQUEST_SCHEME
 CONTEXT_PREFIX
 CONTEXT_DOCUMENT_ROOT
 SERVER_ADMIN
 SCRIPT_FILENAME
 REMOTE_PORT
 GATEWAY_INTERFACE
 SERVER_PROTOCOL
 REQUEST_METHOD
 QUERY_STRING
 REQUEST_URI
 SCRIPT_NAME
 PHP_SELF
 REQUEST_TIME_FLOAT
 REQUEST_TIME

 

Some important server elements


<?php
echo "Host: " . $_SERVER["HTTP_HOST"] . "<BR>";
echo "Browser: " . $_SERVER["HTTP_USER_AGENT"] . "<BR>";
echo "User's IP address: " . $_SERVER["REMOTE_ADDR"]."
";
echo "User's Software: " . $_SERVER["SERVER_SOFTWARE"]."
";
echo "User's name: " . $_SERVER["SERVER_NAME"]."
";
?>

 

Output


Host: localhost
Browser: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
User's IP address: ::1
User's Software: Apache/2.4.4 (Win64) PHP/5.4.12
User's name: localhost

 

Print complete server elements


<?php
echo "Complete Server Details";
foreach($_SERVER as $key => $value){
echo $key."=====".$value."</br>";
}
?>



PHP Interview PDF For Fresher

PHP Interview Question For fresher PDF

PHP Interview Question

pTutorial provides to its user the free interview pdf for fresher as well as experts. PHP is a very popular internet programming language that is basically used for creating dynamic web pages. PHP 5 introduce a lot of object oriented feature.

 

PHP interview question for fresher

These interview questions are very important for fresher who are going your first interview at company level.

This book also contains the PHP 5 MySql Questions, which are very useful for development and as well as for interview.You can easily download by clicking on download button.

Download PHP interview question for fresher