$_SERVER
Last updated
What is $_SERVER?
The $_SERVER is a superglobal in PHP, holding information about headers, paths, and script locations. $_SERVER is an associative array containing server variables created by the web server. This can include specific environmental configurations, the server signature, your PHP script's paths and details, client data, and the active request/response sequence. Among its many uses, $_SERVER['REMOTE_ADDR'] can help get the visitor's IP while $_SERVER['HTTP_USER_AGENT'] offers information about their browser. Don't forget to sanitize the content before use to prevent security exploits.
Here's an easy code sample that prints the client's IP:
echo 'Your IP is: ' . $_SERVER['REMOTE_ADDR'];
Free resources to learn $_SERVER
- Official docs$_SERVER
More in stage 8: Form Processing
$_SERVER: common questions
Can I learn $_SERVER in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain $_SERVER in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this $_SERVER tutorial for beginners?
It is lesson 49 of 120 in the free PHP roadmap, in stage 8, Form Processing. If you are new to PHP, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.