Let's Create Our First Web Page with PHP
Creating your first PHP web page is easier than you think. All you need is a server that can run PHP (like XAMPP, WAMP, or a live server), and a text editor.
Step 1: Create a PHP File
Create a new file and name itindex.php
. In this file, you’ll write your first PHP code.
<?php
echo "Hello, world! This is my first PHP page.";
?>
Step 2: Run the File on a Server
Make sure the file is located in your server’s root directory (e.g.,htdocs
for XAMPP), then open your browser and go tohttp://localhost/index.php
.
You should see the message:Hello, world! This is my first PHP page.
What Just Happened?
Your PHP code was processed by the server, and the result (plain HTML) was sent to your browser. PHP makes it possible to generate dynamic content easily.