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>";
}
?>



how to get form field value in JQuery

JQuery Form Value Example

Simple JQuery example to get the HTML form field value using JQuery. HTML contains various element like text field, text area, radio button, check boxes etc. You can easily get the value of form field using JQuery.

jquery example
 

This tutorial explain you how to get the text field and text area value using JQuery.

To get value of HTMLinput field.


$("input").val();

 

To get value of HTML Text area field.


$("textarea").val();

 

JQuery example

<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

<script>

$(document).ready(function(){

$("button").click(function(){

alert("Text field value- " + $("#test").val());

alert("Text area value- " + $("#test1").val());

});

});

</script>

</head>

<body>



Name: <input type="text" id="test" value="umar farooque">


<textarea id="test1">

ptutorial

</textarea>

<button>Get form field values</button>

</body>

</html>

To learn more about JQuery example and see a lot of live example visit: JQuery Example

Do not forgot to like share and comment

 



Java program to remove string spaces

Java program to remove string spaces ?

Java program to remove leading and trailing spaces from string – the following java program or java source code to remove the space from string using toCharArray() and length with the help of for loop. The toCharArray() is used to convert the string to the character array and length is used to get the length of string.

java example

class A8

{

public static void main(String arr[])

{

int x[],i=0,j=0;

String s="        UmarKhan     ";

char ch[]=s.toCharArray();

int c=ch.length;

x=new int;

for(i=0;i<c;i++)

{


x[i]=ch[i];

}

for(i=0;i<c;i++)

{

if(x[i]!=32)

{

j=i;

break;

}

}

for(i=c-1;i>=0;i--)

{

if(x[i]!=32)

{

c=i;

break;

}

}

for(i=j;i<=c;i++)

System.out.print(ch[i]);

}

}

output

UmarKhan

The following java source code removes the leading and trailing spaces only not in between spaces.

 

For more c example, c tutorial orc tutorial and example PDF visit – java example

Do not forgot to like share and comment