PHP Script Basics

PHP Script Basics

PHP is a scripting language which is used for developing dynamic webpages. Php script and html code can share same file for the development. So to differentiate php code from other stuff. There are four ways to define syntax :

1.  The Most common ways is to use Canonical PHP tags to mark where is php code

   <?php /*place your php code here*/ ?>

 

2. Short-Open tags is the shortest option one can use, but for using this, one must :

  •        Choose the –enable-short-tags configuration option when you’re building PHP script.
  •        Set the short_open_tag setting in your php.ini file to on. This option must be disabled to parse XML with PHP because the same syntax is used for XML tags.

   <? /* Your php code here */ ?>

 

3. ASP style tags are just like actual Active Server Pages tags.  And can be used after some configuration in php.ini file.

   <% your php code %>

 

4. HTML script tags are just how we add any javascript in html. Just replace javascript with PHP and place your code within the script tags.

   <script language="PHP">...</script>

 

The file which contain php code should be saved with .php or any other compatible extension.

Facebooktwittergoogle_pluspinterestlinkedinmail

Leave a Reply