Lesson 1 PHP
Lesson 1 PHP
1. What is PHP?
PHP is a server-side scripting language designed for web development. It's used to create
dynamic websites or static websites or web applications, where the content can change
depending on user input, databases, or other factors.
PHP stand for (Hypertext Pre-processor) that earlier stood for Personal Home Pages.
• Server-side: PHP code runs on the server, and the result is sent back to the user's
web browser as HTML.
• Free and open-source: PHP is completely free to use and has a large community
supporting it.
• WAMP (Windows)
• LAMP ( Linux)
NOUH ABDIRAHMAN 1
Once installed, you can run PHP code by saving it in a .php file and opening it via your local
server (e.g., http://localhost/).
4. Save the file, and go to your browser. Visit http://localhost/index.php to see your
output: Hello, World!
NOUH ABDIRAHMAN 2
3. Basic PHP Syntax
The default PHP file extension is “.php”
A PHP file normally contains HTML tags , and some PHP scripting code
<?php
// PHP code goes here
?>
- Echo Statement:
The echo statement is used to output data to the browser. Example
<?php
echo "Hello, World!";
?>
Output: Hello, World!
In the example below, all three echo statements below are equal and legal
echo"Hello wor";
Echo"Hello word";
ECHO"HELLO WORD";
5. PHP Comments
A comment in PHP code is a line that is not executed as apart of the program. Its only
purpose is to be read by someone who is looking at code.
NOUH ABDIRAHMAN 3
Use comments to annotate code.
o Single-line comments: // or #
NOUH ABDIRAHMAN 4