What is the correct & common way to start and finish a PHP block of code?
The two most common ways to start and finish a PHP script are:
- Using standard tags:
<?php PHP Code here ?>
- Using short tags:
<? PHP Code here ?>
Example 1: Using standard tags:
This is the recommended way.
<?php
echo "I love PHP";
?>
Example 2: Using short tags:
This method is not supported by all server (depending on the PHP configuration), so always use first method.
<?
echo "I love PHP";
?>
Learn more about the similar topics:
Tutorials |
---|
PHP Syntax |
Exercises & Assignments |
---|
Simple Tips for PHP Beginners |
Experiment with Basic PHP Syntax Errors |
Using phpinfo() – Display PHP Configuration & Modules |
Interview Questions & Answers |
---|
What is the correct & common way to start and finish a PHP block of code? |
What is the default extension of the PHP file? |