First Program In PHP
<?php echo “Hello World, This is My First application in PHP”;
?>
Notes:
- Each PHP script should be enclosed within <?php and ?>
- <?php tells the browser that the upcoming lines are PHP script, so PHP interpreter will start its job of translating the code.
- ?> tells the browser that this is the end of the php script. Which means that the interpreter has reached end of the script.
- echo used to print anything you want on the web page.
- If we want to print constant strings like our previous example “hello world…” it should be enclosed within single/double quotes.
- Semi colon: each php statement should be ended with semi colon, which tells the interpreter that this is the end of the statement to be executed. If we don’t end statements with semi colons compilation error will occur, and no output will appear.
Run PHP Script
•To run the previous script of php, and any php script we must follow these steps:
- Save the script in file with extension .php for example anas.php
- Upload it to a server that supports PHP language. (for example: AppServer).
- In order to run it, start your internet explorer, type in the address bar http://localhost then determine port number for example, suppose your server installed on port number 81 then type: http://localhost:81/
- then determine the directory that you saved this script on it. then hit go.
- Save the script in file with extension .php for example anas.php
- Upload it to a server that supports PHP language. (for example: AppServer).
- In order to run it, start your internet explorer, type in the address bar http://localhost then determine port number for example, suppose your server installed on port number 81 then type: http://localhost:81/
- then determine the directory that you saved this script on it. then hit go.
PS, download this lesson as PDF file from here: PHP Tutorial - Lesson 1: Introduction to PHP - Part II
Best Wishes,
Anas Jaghoub
Comments
Post a Comment