How to Write a “Hello World” HTML and PHP Page?
Posted: Wed Apr 22, 2026 8:55 am
If you're starting with web development, one of the first steps is creating a simple “Hello World” page. It helps you understand how web servers, browsers, and code execution work together.
This guide shows both **HTML (static)** and **PHP (server-side)** examples.
---
1. Hello World in HTML (Static Page)
HTML is the simplest form of web content. It runs directly in the browser without a server-side language.
###
Example: index.html
```html
```
###
How it works:
* The browser reads the file directly
* No server processing is needed
* Everything is displayed as written
### ▶ How to run it:
1. Save the file as `index.html`
2. Open it in your browser (double click or drag into browser)
---
2. Hello World in PHP (Dynamic Page)
PHP runs on a server and generates HTML dynamically before sending it to the browser.
###
Example: index.php
```php
```
###
How it works:
* The server executes PHP code
* Only the output is sent to the browser
* The user never sees the PHP source code
---
PHP with HTML Combined
You can mix PHP and HTML in the same file:
```php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Hello World</title>
</head>
<body>
<h1>
<?php
echo "Hello World from PHP!";
?>
</h1>
</body>
</html>
```
Key Difference: HTML vs PHP
| Feature | HTML | PHP |
| ------------- | -------------- | --------------------- |
| Execution | Browser | Server |
| Type | Static | Dynamic |
| Interactivity | Limited | High |
| Use case | Layout/content | Logic + backend tasks |
---
Start simple, experiment often, and gradually build more complex projects.
— TUX Network Team
This guide shows both **HTML (static)** and **PHP (server-side)** examples.
---
HTML is the simplest form of web content. It runs directly in the browser without a server-side language.
###
```html
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
<p>This is my first HTML page.</p>
</body>
</html>###
* The browser reads the file directly
* No server processing is needed
* Everything is displayed as written
### ▶ How to run it:
1. Save the file as `index.html`
2. Open it in your browser (double click or drag into browser)
---
PHP runs on a server and generates HTML dynamically before sending it to the browser.
###
```php
Code: Select all
<?php
// Simple Hello World example in PHP
echo "Hello World";
?>###
* The server executes PHP code
* Only the output is sent to the browser
* The user never sees the PHP source code
---
You can mix PHP and HTML in the same file:
```php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Hello World</title>
</head>
<body>
<h1>
<?php
echo "Hello World from PHP!";
?>
</h1>
</body>
</html>
```
| Feature | HTML | PHP |
| ------------- | -------------- | --------------------- |
| Execution | Browser | Server |
| Type | Static | Dynamic |
| Interactivity | Limited | High |
| Use case | Layout/content | Logic + backend tasks |
---
Start simple, experiment often, and gradually build more complex projects.
— TUX Network Team