Posts Tagged php photos
First PHP Script
Posted by Prabhjot Singh in UltimatePedia on March 8, 2010
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:
Example2:
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? :-
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:















Recent Comments