You are on page 1of 11

1

Created By Sir Hassnain Chachar


2

PHP
3
What is php
PHP stands for “Personal Home Page”.
But now
PHP stands for “PHP Hypertext Preprocessor”.
PHP was originally created by “rasmus lerdorf” in 1995.
PHP is an open-source “server side scripting ” language.

Created By Sir Hassnain Chachar


4
Why we use PHP?

We use PHP to create “Dynamic Web pages/ sites”.


PHP is a widely used free and efficient alternative to
competitors such as Microsoft ASP.
Competitor of PHP:
ASP/ASP.net
JSP
Created By Sir Hassnain Chachar
5
What do I need to run PHP page

Install a web server on your own pc, and then install PHP and
MySQL.

IF
Your server has active support for PHP you do not need to do
anything.
Just create some PHP files place them in your web directory.
And the server will automatically run on web browser.
Created By Sir Hassnain Chachar
6
WEB SERVERS
Mostly we use the following web servers
WAMP
XAMPP
Install the web server start services and then Write the “localhost”
In your browser to check whether it is running or not.

Created By Sir Hassnain Chachar


7
My first page
Open notepad and type the following code

<?php
echo “Welcome to PHP course”;
?>

Save it dot php extension


For example :
Created By Sir Hassnain Chachar
myfirstpage.php
8
How to Run it
Open any web Browser (Google chrome, Internet Explorer etc.)

Write the :

Localhost/myfirstpage.php

Created By Sir Hassnain Chachar


9
Comments
 A comment in php code is a line that is not read as part of the program. Its only purpose is to be read by
someone who is editing the code. So why use comments?
 To let other Know what you’re doing.
 1/ Single line comment.
 2/ Multi-line comment.
.Single line comment.
 // single line comment
 # single line comment
.Multi line comment.
/* multi-line
Comment
*/
Created By Sir Hassnain Chachar
10
Rules to Declare variable in php

 All variable in php start with a ‘$’ sign /symbol.


 A variable name must start with a letter or an underscore ‘_’
sign /symbol.
 A variable name can only contain alpha-numeric characters and
underscores (a-z, 0-9and _)
 A variable name should not contain spaces. If a variable name is
more than one word. It should be separated with underscore
($my_string),or with capitalization ($mystring)
Created By Sir Hassnain Chachar
11
Variables
 .simple definition
Any thing /Quantity which can change its value is called variable.
Or
Variables are used for storing values, such as numbers, strings.
 Why we use it?
We use variable to store different values.
 How to declare variable in php?
In php variable start with the $ sign, followed by the name of the variable .
Syntax : $var_name =value;
Example :-
Created By Sir Hassnain Chachar $x=10;

You might also like