Welcome to the PHP tutorial! In this lesson, you will learn what PHP is, why it is used, its features, and how to write your first PHP program.
PHP stands for PHP: Hypertext Preprocessor. It is a popular server-side scripting language used to develop dynamic websites and web applications.
PHP code runs on a web server. The server processes the PHP code and sends the resulting output, usually HTML, to the user's browser.
<?php
echo "Hello, World!";
?>
Hello, World!
The echo statement displays output.
The PHP opening tag is <?php,
and the closing tag is ?>.
Server-side scripting means that code is executed on a web server instead of directly in the user's browser.
For example, when a user opens a PHP page:
PHP is commonly used for form processing, database operations, login systems, and content management.
PHP can be used to create:
For example, you can use PHP and MySQL to build a student registration system that stores student details in a database.
PHP can be written inside an HTML file saved with
the .php extension.
<!DOCTYPE html>
<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<h1>Welcome to PHP</h1>
<?php
echo "I am learning PHP.";
?>
</body>
</html>
I am learning PHP.
Save this example as first.php and run
it through a PHP-enabled web server. Opening the file
directly in a browser will not execute the PHP code.
PHP files commonly use the .php extension.
| File Name | Purpose |
|---|---|
| index.php | Main website page |
| login.php | Login processing |
| register.php | User registration |
| database.php | Database connection code |
Complete the following tasks:
first.php.echo statement.<?php
echo "My Name is Rahul";
echo "<br>";
echo "Welcome to Soopro Pathshala";
?>
Replace Rahul with your own name.
1. What does PHP stand for?
2. Where is PHP code normally executed?
3. Which extension is commonly used for PHP files?