Search for a tutorial

User submitted
• User navigation
• Other content

Before a PHP script will execute, the server must be instructed to execute it. To do so, we must enclose the script block in a special set of tags, that lets the server know what is PHP code. When the server encounters a PHP open tag, everything between there and the close tag is executed, between there and the close tag is executed as PHP. The PHP open tag is:

<?php and the close tag is ?>

Alternatively <? ... ?> can be used. The <?php opening tag is the preferred method, as this allows for PHP within XML-conformant code. Generally, either method is accepted and it is mostly a matter of taste.

Another method will also open and close PHP script: to enable this option, the php.ini file must be modified, to open and close a block of scripts. In the php.ini file, find the line with asp_tags and change it from asp_tags = Off to asp_tags = On. Using the ASP tags format is also a largely a matter of taste and style.

Note - The <?php ... ?> style is the most recommended and is the one that you will learn to use a lot.

Generally when introducing yourself to PHP, learning the print query first is very common and simple for your understandment.

Create a new document, in notepad, or any web page editor of your choice, If you are using any programs like, Macromedia Dreamweaver MX, or Microsoft Frontpage, Make sure you load the Source code/HTML code view.

When you have created the new document. Simply type the code in below.

<?php print('Hello, Everyone!\n'); ?>

The print tag basically prints the text you have typed in inside the print tags.

When you upload your php file to your php web server, the page will show : Hello Everyone.

I hope this tutorial was easy for you to understand, please view some of our other tutorials.

Thanks