Step 1: Create a new PHP file
1. Using Zend Studio for Eclipse or any IDE or text editor, create a file containing the following text:
- <?php
- echo "Hello, World";
- ?>
2. Save this file as 'hello1.php'.
See Behind the Code for an explanation of this code sample.
Step 2: Copy the file to your Zend Server's document root
Step 3: Run your application
Open a Web browser and browse to the URL of your file, located at http://localhost:<port>/hello1.php .
- Replace <port> with the port number on which your Web server listens.
- What is my port number?
Congratulations
You have just run your first PHP script using Zend Server. The words “Hello, World” will be displayed in your browser.
What next?
- See Behind the Code, below, to learn about the PHP code you have just run.
- Access more sample applications which can be run on the Zend Server.
- To learn more about PHP basics, check out the PHP 101 category in the Zend Developer Zone.
Behind The Code
- <?php
- echo "Hello, World";
- ?>
The “Hello World” sample application is a basic PHP application which displays the words “Hello, World” in a browser. Learning how to display the words “Hello, World” on a screen is a common first lesson for most programming languages.
Let's break up the code in our application to see what each line is doing:
- <?php
This line contains the opening PHP tag. PHP was originally designed to be embedded into HTML or other markup formats such as XML. In order to let the PHP interpreter know that the code to be run is PHP code, the relevant code needs to be enclosed in PHP tags. Any text which is not enclosed in PHP tags will not be evaluated by the PHP interpreter, and will be printed directly to the browser.
- echo "Hello, World";
The second line is where the magic happens. The 'echo' function tells PHP to print something to the screen. The words enclosed in quotes tell PHP what to print – in this case, the words “Hello, World”. The semicolon at the end of the line tells the interpreter that this is the end of the instruction. Most instructions in PHP must end with a semicolon.
- ?>
This is the closing PHP tag.
Tip: The ending PHP tag is optional, and unless you plan to have HTML or other output after the PHP block, you can omit it.


