PHP program to print the server name or website name

Here, we are going to learn how to print the server name or website name in PHP?
Submitted by Nidhi, on November 24, 2020

Here, we will use $_SERVER['SERVER_ NAME'] superglobal to get the server or website name and then print that on the webpage.

Program/Source Code:

The source code to print the server name or website name is given below. The given program is compiled and executed successfully.

//PHP program to print the 
//server name or website name.

$ServerName = $_SERVER['SERVER_NAME'];

printf("Server Name: %s<br>", $ServerName);


Server Name:


In the above program, we used $_SERVER['SERVER_NAME'] super global that returns the server or website name, which is assigned to the variable $ServerName. After that, we printed the server or website name on the webpage.

More PHP Programs »



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.