Sunday, 11 November 2012

echoing with PHP

Printing 'hello world' is the way in which every programmer begins his/her learning and  that is exactly what are we going to do in here.
First open your notepad and type the following code:
                                           <?php 
                                               echo "hello world!";
                                            ?>
and save it as "hello_world.php" do not forget to add double quotations otherwise notepad will append a .txt format after 'hello_world.php' and will become 'hello_world.php.txt' and it will not be executed as a php code.
Then put it inside your web directory( if you are using Easy Php your default web directory is 'www' which is situated inside the easy php folder).Then run it from your web browser.just type http://127.0.0.1/hello_world.php or http://localhost/hello_world.php on the address bar of your browser and it will print 'hello world' as expected.
Now lets make it more interesting.Lets say we want to add two number and echo out its output.
                                             <?php
                                                  $a=5;
                                                  $b=6;
                                                  $c=$a+$b;
                                                  echo  $c;
                                                 ?>
 and run it as http://localhost/filename.php and you will be able to see 11.Now see the difference here we echo out but do not use a double quotation.This is not a mistake, we did it intentionally as we are echoing a variable when we are printing some variable we do not need to double quote it but for strings we double quote it.lets take a look at the example below:

                                              <?php
                                                  $a=5;
                                                  $b=6;
                                                  $c=$a+$b;
                                                  echo " $c";
                                                 ?>
if we do this then the result will be $c because now that we have double quoted it it is no longer a variable, it is now a string( remember a 'string' not 'string variable').


Saturday, 10 November 2012

php basic(Hello World!)

                                                                      <?php
                                                                              echo "Hello World!";
                                                                       ?>

what we did here is we printed out the string 'Hello World!'.Now before we start coding i am assuming that readers dont know what php is and what does it do.
There are two types of programming (1) Client side programming
                                                       (2) Server side programming

Client side programming is a class of computer programs that executes on client side i.e browser.This is an important part of website .Because what we see on our browser those buttons and texts they are all creation of client side programming.There are many language that is used as client side scripting such as Java Script.
Server side programming on contrary does not execute on browser or client side instead they execute on servers.So when the above code is executed on web server it returns plain html and send it to client.The below picture explains it more beautifully     


Whenever you type a web address and hit enter the server sends a request to the server and the server processes the request and interprets the php and return the html file which hold 'Hello World!' and prints it to the client's browser.There are lots of client side programming language like ASP(Active Server Pages),JSP(Java Server Pages) and last but not the least PHP. Among these all which one is the best is still a matter of argument.But i am more fond of PHP as it is easy and it is free it has the widest support across the web and it executes really fast which makes it our language of choice.
In the next post we will be doing a little php coding.Stay tuned.






EasyPHP

Today i am going to talk about one of very useful and my personal favorite tool for website development.

We all know how much time it takes to configure php and mysql and apache etc.At first you have to learn how to configure these things but when you are in hurry or you are building a website then it will be annoying task to do.

But i found a solution. EasyPhp is product that includes php MyAdmin,MySql,a full apache web server and php 5.X all configured in one tiny package.All you have to do is to download it from easyphp.org and install it.The best part of it is that it is  free.

You do not need to configure any thing just install it and run it.

There is web directory names 'www' inside easyphp folder.This is the folder where you will be putting all your html and php files.


 After running it from the start menu go to the 'show hidden icon' menu on the task bar(for win 7) for xp it is clearly visible 'e' sign on the task bar beside the clock.Right click on that icon and then click on local web.
It will open a page in your default web browser where you will be able to see all your php and html file.

Wednesday, 7 November 2012

My first post.

Hello all,today i will be posting about how i began learning computer and it will be in some point will coincide with the experience of all who love computer and love to code.
I first gained my interest in computer when i was in 5th stander(as far as i can remember).My brother took me to his office to let me touch their PantiumIII computer.The first keys that i touched that were the arrow keys(i was playing Road Rush :-)).And then it all started, i fell in love with that machine.At that time I couldn't afford a PC so I got my admission to local computer center so that i can spend my weekends with computers.
I got my first PC when I was 17 years old.The first language that i learned was BASIC.But at that time computer games were the most lovable thing to me.The first game on my PC was DOOM2.
When I was 18 i learned Visual BASIC and it was fun.You did not have to code Forms and text boxes and buttons.All you had to do is to drag and drop the elements and double click to add actions.
But recently i am interested in Website design so i will be posting about my experience about website design.