First PHP Script

So if you have downloaded the WAMP server and get it installed on your machine then now you are ready to make your debut in PHP scripts.

COMMON ONE’S

  • Syntax: Every php statement will follow a common pattern like this:-

<? php

—————

—————

?>

As Php interpreter will only read those instructions which are inside the “<——–?>” php tags.

  • Semicolon: Every of the php statement inside the php tags will end via a semicolon “;”.

{Exceptional case}: Whether to mark the end of a php statement with or without semicolon, is the common area of error. It’s not every time that you have to put a semicolon over there, exception do exists.

Example1:

<?php echo “case 1″ ?>

Example2:

<?php echo “case2″;  echo “semicolon present” ?>

So as you see in the above examples in case1 where a single statement exists you can omit putting semicolon, as this”?>” closing of php will automatically includes a semicolon. But while there are multiple statements as in case2, you can’t omit the semicolon.

  • Comment: As simple as in javascipt.

<? php

//for a single line statement

?>

 

<? php

/* for

multiple line

statements */

?>

 

Let’s Start:

So after having an idea about the Php scripts structure now you can easily write one for yourself.

Step1: Open any of the text editor(notepad or notepad++).

Step2: Write any simple script, how about displaying something on the webbrowser? :-

<?Php echo”welcome to php” ?>

Step3: Save this with a “.php” extension. And please remember if you are saving using notepad don’t forget to put double quotes while specifying the file name or otherwise you will land with a text file.

EXECUTE & VIEW

Step1: Install WAMP server:

As installation about to complete, it will ask you to specify your browser location.

So specify where your browser file is located:

Step2: Left click on the WAMP server icon on the taskbar. Remember it’s left click not the usual right one.

Step3: Click on “localhost”.

Something like this would appear on your browser.

Step4: Now you will have to create a folder at “c:\wamp\www\” or wherever you have installed wamp server (let the folder name ultimatechange).  Basically we create this folder for simple accessibilty, so that we can have a single location where all our projects can be stored and can be accesed as require.

And then simply drag and drop the PHP-file which you have created above at this location:- ”c:\wamp\www\ultimatechange”.

Step5: Now refresh your browser. And you will see the folder which you had created above.

So click over the new folder which you created and you will get:

Step6: Here you can see “script1.php” the file which you created is appeared, so click it to see the output of your first php script:

Share This Post

, , , , , ,

1 Comment

All About PHP

 

A B C Of PHP

  • PHP stands for Hypertext Preprocessor.
  • It’s a server side scripting language, like ASP.NET, JSP, Perl etc.
  • It is an interpretted language, means no need for compiling PHP programs before executing them.

Current Version

Current version while writing up this post is PHP 5.3.2.

Basic Funda Of PHP

Step1: Assume you open your web browser and type in any URL (let it be ultimatechange.co.cc). So now your web browser will send a request to the corresponding server (of this URL).

Step2: The web server on the other hand receive this request. It spots out that this URL ends with “.php” extension and so it send this request to the PHP interpreter which is present in the server only (consider the interpreter to be a part of server for now).

Step3: The PHP interpreter accepts the request send to it by the server. It then starts executing whatever PHP-tags are associated with that particular request (hope you have little idea about tags, if not then consider it to be as some code for now).

As execution is completed the response (result) is sent back to your browser. And finally what you get to see is ultimatechange.co.cc blog or whatever you have requested for.

What Makes It Special? 

Server Side Player: As discussed above PHP code is processed at the server side and not on client’s browser. Now this may sound you very normal thing, but even this little thing make a big difference. How?  Actually what happens is for all client side scripting languages(yes the one which are executed at your end) a complex logic is required for providing browser specifications. But with server side  scripting like PHP, anyone can easily write any program irrespective of client’s browser specifications.

Source Code Privacy: Yeah that’s another remarkable feature of PHP. And the credit for this again goes to server side scripting only. As all the PHP-tags are processed at the server side and only the result is send to the client, thus hardly you can see what’s the source code of the webpage is.

Requirements

Generally WAMP server is used when you want to try out your hands with PHP on windows. This WAMP server basically comprises of 4 components Windows, Apache, MySQL, PHP.

Now you might be amazed by reading out all these components, some of us will say when we can easily write out this PHP at notepad then why we will require all this things? So to answer your this query i want to drag your attention back to “Funda of PHP“, over their i told you that you client working on your system, request server which passes ahead the same to interpreter and so on.. So now considering you as a beginner to this language, i will recommend you to first practise out your PHP scripts on your system only. And once you have enough practice with it, then definately you can move on by simply writng PHP in notepad and then uploading files on FTP sever.

So for building and then testing all your PHP scripts locally on your machine, requires a specific environment comprises of:

  • An operating system where client work and a server environment(usually linux).
  • A webserver (usually apache on linux, while IIS on windows).
  • PHP interpreter to process all PHP codes.
  • Database (MySQL) to hold all data.

And that’s the reason why we choose WAMP server( for windows) or LAMP server (for linux).

Share This Post

, , , , , , , , , ,

2 Comments

“IPL3, Let’s fight again”-News My Way

RWelcome sir over here on ultimatechange, a blog which really loves to interview newsmakers like you.

Afridi: {Smiling heavily} Allah! so finally i got to hear someone who really admires me.

R: {Pausing for a moment} Sir i’m sorry to say but you might seem to get into some kind of misunderstanding, i have not uttered a single word praising you out.

Afridi: Arrey, tagging out newsmaker with my name that’s enough for me. Anyway you carry on..

R: Okay as you like…

Sir, as we all recently witnessed in the IPL3 auction, not even a single Pakistan player got picked up.  Being as a senior pakistan player, does it really matters to you? or you just don’t mind this at all?

Afridi: Look, the moment opponent’s team player stares at me, i spontaneously burst out on him with my abusive dictionary. So how can people like you imagine that i don’t mind this at all?

Afridi: Moreover it is a million dollars deal. And it really matters to me, specially when it comes dealing in foreign currency.

R: Yeah sir everyone knows, how much pakistani people likes foreign currency. After all, every year you people get a huge sponsorships from U.S.

R: {Moving to next question} Sir, recently pakistan media broadcasted that this was the conspiracy build by Indian government to humilitate pakistan on a very big stage. Do you agree with them?

Afridi: Yeah absolutely.. But when for so many years our country had executed thousands of conspiracies against india, then in front of it we not all mind this one, after all finally India had stared to follow our footsteps.

R: But don’t you sir really feel humiliated by this kind of treatment, which you got from IPL teams, franchies, BCCI, Team managements?

Afridi: Hmm… a kind of, but to be very honest loosing out to Australia even  bowling them out for 127 in the recent test match at sydney was much more shameful.

R: But sir, you also recently got sacked by ICC for the bowl tempering issue. Wasn’t that the most humiliated moment for you?

Afridi: Oh no way, it just an another part of planning & plotting against me.

R: But sir, footages clearly shows that ball was in your mouth. You were trying out something with it….

Afridi: Er…er.   I…..I…. It’s just nonsense. I can prove myself being framed out.

R: But how sir?

Afridi: Did you remeber the IPL season1? Remember the case when Bhaji slapped Sreesanth badly?

R: Yeah sure sir, but what all this to do with the ball in your mouth?

Afridi: You fool… Wasn’t that a big crime, slapping out your team mate instead of oppostion player? And still no footage of this leaked out in media. So how can this of mine footage can be presented out?

Afridi: This purely reflects that this one is just a manipulated video, it would be some kind of situation where i would be eating out something like an apple and some fellow had just replaced it with the ball.

R: {Oh my god!! what a reasoning} Anyway sir, just a last question to you.

R: Every one is really anxious to know about the current status of PPL(Pakistan Premeire League)? Any comment regarding it?

Afridi: Right now we would prefer to focus on internationals tournements (after all setting up a premiere league requires lots of sponsorship & right now pakistan millionaires prefer to invest in terrorism then in cricket).

R: We really apprecitate that you joined with us.

Afridi: I too thanx you for tagging newsmaker word with me.

Blog Widget by LinkWithinShare This Post

, , , , , , ,

No Comments

This site is protected by WP-CopyRightPro