Sunday, February 1, 2009

free PHP training in 1 month(Part III)




Hi all,


Sorry i was busy.Now let start our first hello world program from PHP.

Steps:

1- Open your NetBeans IDE from Start Menu.

2-Go to File/New Project/Select PHP from Category/PHP application/Next/Give HelloWorld to application name/Click Finish.

After you finish you will see a page with a bloc of code for index.php.I will will explain to you more about this file later.



// put your code here
?>


Note1:
Every php application starts with .
The php code goes within

Note2:

You declare php variable with a dollar sign $ follow by the name of the variable.
For more info about definition go to php.net/documentation.

Let declare a variable named i and assign it 12;

$i='Hello World';

Note 3:
Single quote is best way to handle string.Do not use "" for strings.Any variable
within "" will be Executed.

Note 4:
Php comment is c# style // or /* */
Let print it to the browser.The best browser for php is FireFox.
Right click on the projoect HelloWorld/Properties/Debug/Deselect Debug Server with php/Seelect Debug client with Javascript/Choose FireFox and click OK.

Now let print $i to the browser.
add code like this:


$i='Hello World;
//to print hello world we use echo keyword or print

echo $i;


?>

Note 5:Every variable declaration end with ; like c#

Run the project :Right click on index.php/Run.

You will see Firefox showing Hello World.

Note6:
PHP is a loosy type.It mean you don`t have to define a variable type to use it.
Let me be clair.In C# if i want to declare an integer variable named i this is how i
will do it:

int i=12;
In php $i=12;so php is less trouble than c#,vb......

See you Next time.Remember to go to documentation section of php.net and copy
php keyword to a file named keyphp.txt on your desktop.

Talley John
Software Developer

1 comment:

NavneetSharma said...

hi you got a nice blog!!
quite informative…
www.learnphpinchd.blogspot.com

About Me

My photo
Raleigh, NC, United States
I am a software developer based in Raleigh,NC,USA.I design softwares and systems ;i also do consulting for companies worldwide.I program with these languages:VB.NET 2003/2005/2008;C#;Java(fun),SQL(200,2005,2008);ASP.NET 2.0/3.5;ASP.NET AJAX;ASP.NET MVC;JavaScript;JQuery;Windows Workflow Foundation;Web Services.I have 4 years + in programming.