PHP – How to Start With?

Posted by tutor | Posted in PHP Tutorial | Posted on 11-12-2009-05-2008

0

Every language has some rules to how to write them or all languages has some defined words which must be used to make a meaningful sentence. Like that PHP too has some rules that must be followed to write properly structured code, which could be understood by the PHP interpreter.

PHP is similar to most of the other programming languages (C, Java, and Perl) in syntax and semantics.

All PHP code is contained within a tag. As PHP is less often used stand alone so all the PHP code is written within a tag which marks the beginning and the end of PHP code.

<?php
//Your PHP code goes here
?>

Or you can use the shorthand

<?
//Your PHP code goes here
?>

However, if you are using multiple scripting languages then you must use the former to avoid confusion and mixing of all the codes.

PHP code written outside this tag will not be interpreted and will be directly displayed on the browser as some jumbles.

A PHP block can be anywhere in your page.

Saving Your PHP Pages

A PHP file is a file with extension “.php”, “.php3″, or “.phtml”. It can be written in any SDI (Single Document Interface) like notepad, and save with any of the three extensions.PHP files can contain text, HTML tags and scripts.

PHP scripts runs on the server, when a browser sends request PHP files are returned to the browser as plain HTML

If you have inserted PHP into your HTML page, then you must save the file with a .php extension, instead of the standard .html extension, then only it will be interpreted as some script otherwise it will be displayed as it is.

Write a comment

Twitter Users
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.