Saturday, 9 February 2013

Online PHP Programming Tutorial: Learn Basics of PHP Scripting With Simple PHP Code and Examples (Part 1)

Online PHP Programming Tutorial: Learn Basics of PHP Scripting With Simple PHP Code and Examples (Part 1)

Introduction to PHP: PHP stands for Hypertext Preprocessor. PHP is a server scripting language and is used for creating dynamic web pages. PHP is an open source scripting language. We will discuss some similarities and differences between PHP and ASP.NET later in this tutorial.

Learning PHP Programming

Learning PHP programming and development is very easy. PHP has very simple syntax. In this online PHP tutorial, we will learn PHP step by step by simple PHP examples using short and simple PHP scripts and codes. Lets start learning PHP scripting now:

1. Simple PHP Code Snippet

<?php
echo "Lets learn PHP Programming!";
?>

Some basic things to note in PHP scripting:

1. A PHP script starts with <?php and ends with ?>.
2. Each code line in PHP must end with a semicolon.
3. PHP files have a default file extension of ".php".
4. In PHP, there are two basic statements to output text in the browser: echo and print.

2. Comments in PHP Programming

<?php
//PHP Single Line Comments
/*
PHP
Multi Line Comments
*/
?>

3. Rules for PHP Variables

1. PHP variable starts with the $ sign, followed by the name of the variable
2. PHP variable name must begin with a letter or the underscore character
3. PHP variable name only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
4. PHP variable name should not contain spaces
5. PHP variable names are case sensitive ($y and $Y are two different variables)
6. PHP has no command for declaring a variable
7. PHP variables can be local, global and static
8. PHP string variable is used to store and manipulate text. When you assign a text value to a variable, remember to put single or double quotes around the value.

PHP Variables Example

<?php
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>

4. PHP is a Loosely Typed Language

You don't have to declare data type the variable in PHP. PHP automatically converts the variable to the correct data type, depending on its value. In a strongly typed programming language, we will have to declare datatype of the variable before using it.

Consider the following simple PHP example:

$txt="PHP is a loosely typed language";
$x=5;

After the execution of the statements above, the variable txt will hold the value Hello world!, and the variable x will hold the value 5. When you assign a text value to a variable, put quotes around the value.

5. Types of Array in PHP

In PHP, there are three types of arrays:

Indexed arrays - Arrays with numeric index
Associative arrays - Arrays with named keys - Associative arrays are arrays that use named keys that you assign to them.
Multidimensional arrays - Arrays containing one or more arrays

Similarity and Differences between PHP and ASP.NET

PHP is a strong competitor of Microsoft ASP.NET. PHP goes ahead of ASP.NET in some case like:

1. PHP runs on different platforms likeWindows, Linux, Unix, Mac OS X, etc. ASP.NET on the other hand, only runs fine on Windows.


2. PHP is compatible with both Apache, IIS while ASP.NET has compatibility only with IIS. You can configure ASP.NET to run on Apache, but that is cumbersome.

3. PHP is open source and free. No license required for using PHP for commercial purposes.
 
Similarity between ASP.NET and PHP

1. Both ASP.NET and PHP are used for dynamic webpage development.


2. Both ASP.NET and PHP are easy to learn and understand.

3. Both ASP.NET and PHP have support for a wide range of databases.

4. Both ASP.NET and PHP have large online developer forums to support web development. For example, you will find a large community of ASP.NET and PHP developers on StackOverflow.com.

7 comments:

  1. Great post. Love to read and share this. You have explained very well Naresh. Thanks for the share

    ReplyDelete
  2. Nice php programming tutorials. Thanks for sharing the php code.

    ReplyDelete
  3. Hi,

    Recently I came across some great articles on your site.
    The other day, I was discussing (http://theprofessionalspoint.blogspot.in/2013/02/online-php-programming-tutorial-learn.html)with my colleagues and they suggested I submit an article of my own. Your site is just perfect for what I have written!
    Would it be ok to submit the article? It is free of charge, of course!

    Let me know what you think
    Contact me at anelieivanova@gmail.com

    Regards
    Anele Ivanova

    ReplyDelete
  4. I believe Web time sheet software makes the complete employee time clock tracking task easier. Its easy to update, approve and maintain the time sheets in no

    time.Time Attendance System

    ReplyDelete
  5. Hi, nice description.Thanks for your help..

    -Aparna
    Theosoft

    ReplyDelete
  6. http://www.burbagssale2013.com/ Burberry Outlet
    http://www.airmaxshoesfactory.com/ Air Max Shoes
    http://www.coachblackfriday2014.com/ Coach Black Friday
    http://www.coach-storeoutletonline.com/ Coach Black Friday
    http://www.coachcoachoutlet.com/ Coach Cyber Monday
    http://www.coachxfactory.com/ Coach Factory
    http://www.coach-factoryoutletonline.net/ Coach Outlet Factory
    http://www.coach-outletonlineusa.com/ Coach Outlet USA
    http://www.coach-pursesfactory.com/ Coach Purses Factory
    http://www.coachpurseusa.com/ Coach Purses USA
    http://www.coach-storeoutlet.com/ Coach Store Outlet
    http://www.coach-pursesonline.com/ Coach Purses On Sale
    http://www.monsterbeatsbydres.com/ Monster Beats Outlet
    http://www.louis-vuittonblackfriday.com/ Louis Vuitton Outlet
    http://www.lv-guccishoesfactory.com/ Louis Vuitton Factory
    http://www.marcjacobsonsale.com/ Marc Jacobs On Sale
    http://www.mcmworldwides.com/ MCM Outlet
    http://www.mcmoutlet-jp.com/ MCM 店铺
    http://www.oakleysunglassesfactory.com/ cheap oakley sunglasses
    http://www.michaelkorsmas.com/ Michael Kors Outlet
    http://www.michaelkors.so/ Michael Kors Outlet
    http://www.michaelkorsfactory-store.com/ Michael Kors Factory
    http://www.michaelkorsoutletr.com/ Michael Kors Outlet
    http://www.michael-korsfactoryonline.com/ Michael Kors Factory Online
    http://www.newcoachfactoryoutlet.com/ Coach Factory Outlet
    http://www.north-faceoutletonlines.net/ North Face Outlet Online
    http://www.polo-outletstore.com/ Polo Outlet Store
    http://www.ralph-laurenhome.com/ Ralph Lauren UK
    http://www.saclongchamppairs.com/ Sac Longchamp Pairs
    http://www.tcoachoutletonline.com/ Coach Outlet Online
    http://www.the-coachfactoryoutlet.com/ Coach Factory Oultet
    http://www.barbour-jacketsoutlet.com/ Barbour Jackets Outlet Online
    http://www.canada-gooser.com/ Canada Goose Outlet
    http://www.guccishoesuk-2014.com/ Gucci Outlet Online
    http://www.michaelkorsstates.com/ Michael Kors Outlet
    http://www.moncler-clearance.com/ Moncler Clearance
    http://www.famousbagsmall.com/
    http://www.moncler-jacketsoutletonline.com/ Moncler Jackets Outlet Online
    http://www.northsclearance.com/ North Clearace Outlet
    http://www.polo-ralphlaurenonline.com/ Polo Ralph Lauren Outlet Online
    http://www.woolrich-clearance.com/ Woolrich Clearance
    http://www.cvshopfactory.com/ shop.coachfactory.com
    http://www.mksfactoryoutlet.com/ Michael Kors Factory Outlet
    http://www.zxcoachoutlet.com/ Coach Outlet Online USA
    http://www.thebeatsbydre.net/ Beats by Dre
    http://www.vipbagsmall.com/
    http://www.newoutletonlinemall.com/ Coach Purses Outlet Online
    http://www.clickmichaelkors.com/ Michael Kors USA

    ReplyDelete