SlideShare una empresa de Scribd logo
1 de 59
NIDHI
MISHRA
PHP
Introduction to PHP:-
 PHP is a server scripting language, and a
powerful tool for making dynamic and interactive
Web pages.
 PHP stands for “PHP: Hypertext Preprocessor”.
 Syntax based on Perl, Java , And C.
 Very good for creating dynamic content.
 PHP is a widely-used, free, and efficient
alternative to competitors such as Microsoft's
ASP.
 Powerful, But somewhat risky!
History:-
 Started as a Perl hack in 1994 by Rasmus
Lerdorf (to handle his resume), developed
to PHP.
 By 1997 up to PHP 3.0 with a new parser
engine by Zee Suraski and Andi Gutamns.
 Version 5.2.4 is current version, rewritten
by Zend to include a no. of features, Such as
an object model.
 Current is version 5.
How To Run Program In PHP:-
 URL Open.
 Server Must Be ON.
 URL Address:- 127.0.0.1/folder name/file name
or
local host/folder name/filename
PHP Scripts:-
 Typically file ends in “.php”- -this is set by the web
server configuration.
 Separated in files with the <?php ?>.
 PHP commands can make up an entire files, or
can be contained in html- -this is a choice….
 Program lines end in “ ; ” or we get an error.
 Server recognizes embedded script and executes.
 Result is passed to browser, Source isn’t visible.
Example of PHP Script:-
 <!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP
script!";
?>
</body>
</html>
Output:-
My first PHP script!
String Print:-
 “ ”
 ‘ ’
 ;
 “ ‘ ’ ”
 ‘ “ ” ’
Note:- If we want embed another
language, like HTML in PHP then all
HTML works as a string.
PHP echo and print statements:-
 echo and print are more or less the same.
They are both used to output data to the
screen.
 The differences are small: echo has no
return value while print has a return value
of 1 so it can be used in expressions. echo
can take multiple parameters (although
such usage is rare) while print can take one
argument. echo is marginally faster than
print.
Example of echo statements:-
 <!DOCTYPE html>
<html>
<body>
<?php
echo "<h2>PHP is
Fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn
PHP!<br>";
echo "This ", "string ", "was
", "made ", "with multiple
parameters.";
?>
</body>
</html>
 Output:-
PHP is Fun!
Hello world!
I'm about to learn PHP!
This string was made with
multiple parameters.
Example of print statements:-
 <!DOCTYPE html>
<html>
<body>
<?php
print "<h2>PHP is
Fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn
PHP!";
?>
</body>
</html>
 Output:-
PHP is Fun!
Hello world!
I'm about to learn PHP!
PHP Variables:-
 Rules for PHP variables:
- A variable starts with the $ sign, followed by the
name of the variable.
- A variable name must start with a letter or the
underscore character.
- A variable name cannot start with a number.
- A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ ).
- Variable names are case-sensitive ($age and
$AGE are two different variables).
PHP Data Types:-
 Types of declaration of variable is known as Data Type.
 PHP supports the following data types:
- String
-Integer
-Float (floating point numbers - also called
double)
-Boolean
-Array
-Object
-NULL
-Resource
PHP String:-
 <!DOCTYPE html>
<html>
<body>
<?php
$x = "Hello world!";
$y = 'Hello world!”;
echo $x;
echo "<br>";
echo $y;
?>
</body>
</html>
 Output:-
Hello world!
Hello world!
PHP Integer:-
 An integer data type is a non-decimal number
between -2,147,483,648 and 2,147,483,647.
*Rules for integers:
 An integer must have at least one digit.
 An integer must not have a decimal point.
 An integer can be either positive or negative.
 Integers can be specified in three formats:
decimal (10-based), hexadecimal (16-based -
prefixed with 0x) or octal (8-based - prefixed with
0).
Example of PHP Integer:-
 <!DOCTYPE html>
<html>
<body>
<?php
$x = 5985;
var_dump($x);
?>
</body>
</html>
 Output:-
int(5985)
Example PHP Float:-
 <!DOCTYPE html>
<html>
<body>
<?php
$x = 10.365;
var_dump($x);
?>
</body>
</html>
 Output:-
float(10.365)
PHP Boolean:-
 A Boolean represents two possible states:
TRUE or FALSE.
 $x = true;
$y = false;
Booleans are often used in conditional
testing. You will learn more about
conditional testing in a later chapter of this
tutorial.
PHP Arrays:-
 An array stores multiple values in one single
variable.
 Example
<?php
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>
 Output:-
array(3) { [0]=> string(5) "Volvo" [1]=> string(3)
"BMW" [2]=> string(6) "Toyota" }
PHP Objects:-
 An object is a data type which stores data
and information on how to process that
data.
 In PHP, an object must be explicitly
declared.
 First we must declare a class of object. For
this, we use the class keyword. A class is a
structure that can contain properties and
methods.
PHP Null Value:-
 Null is a special data type which can have
only one value: NULL.
 A variable of data type NULL is a variable
that has no value assigned to it.
Note: If a variable is created without a
value, it is automatically assigned a value of
NULL.
Variables can also be emptied by setting the
value to NULL:
Example of PHP Null Value:-
 <!DOCTYPE html>
<html>
<body>
<?php
$x = "Hello world!";
$x = null;
var_dump($x);
?>
</body>
</html>
 Output:-
NULL
PHP Operator:-
 Operators are used to perform operations on
variables and values.
PHP divides the operators in the following
groups:
 Arithmetic operators. (For normal operations)
 Assignment operators. ( = )
 Relational operators. ( < , > , < = , = > )
 Logical operators. ( and , or )
PHP Conditional Statements:-
In PHP we have the following conditional statements:
 if statement - executes some code if one condition
is true.
 if...else statement - executes some code if a
condition is true and another code if that condition
is false.
 if...elseif....else statement - executes different
codes for more than two conditions
 switch statement - selects one of many blocks of
code to be executed.
PHP- The If Statement:-
 The if statement executes some code if one
condition Is true.
 Example Output:-
<?php Have a good day!
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
}
?>
PHP- The If ... Else Statement:-
 It executes some code if a condition is true and another
code if that condition is false.
 Example:- Output:-
<?php
$t = date("H"); Have a good day!
if ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
PHP- The If .. Elseif..else Statement:-
 The if....elseif...else statement executes different
codes for more than two conditions.
 Syntax
if (condition) {
code to be executed if this condition is true;
} elseif (condition) {
code to be executed if this condition is true;
} else {
code to be executed if all conditions are false;
}
Example If .. Elseif..else Statement:-
 <?php Output:-
$t = date("H");
if ($t < "10") { Have a good day!
echo "HII!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
The PHP Switch Statement:-
 “Use the switch statement to select one of many blocks of code to be executed”.
 Example:-
?php
$color = "red"; Output:-
switch ($color) {
case "red": Your color is red!
echo "Your color is red!";
break;
case "blue":
echo "Your color is blue!";
break;
case "green":
echo "Your color is green!";
break;
default:
echo "Your color is neither red, blue, nor green!";
}
?>
How To Get Form Value:-
Super Global Variable
 $_GET [‘ ’];
 $_POST [‘ ’ ];
 $_REQUEST_ [‘ ’];
How To upload image on a server:-
PHP Loop
In PHP, we have the following looping
statements:-
 while - loops through a block of code as
long as the specified condition is true.
 do...while - loops through a block of code
once, and then repeats the loop as long as
the specified condition is true.
 for - loops through a block of code a
specified number of times.
 foreach - loops through a block of code for
each element in an array.
PHP for loop:-
 The for loop is used when you know in advance
how many times the script should run.
Parameters:
 init counter: Initialize the loop counter value.
 test counter: Evaluated for each loop iteration. If
it evaluates to TRUE, the loop continues. If it
evaluates to FALSE, the loop ends.
 increment counter: Increases the loop counter
value.
Example 1 of for loop:-
 <!DOCTYPE html>
<html>
<body>
<?php
for ($x = 0; $x <= 10;
$x++) {
echo "The number is:
$x <br>";
}
?>
</body>
</html>
 Output:-
The number is: 0
The number is: 1
The number is: 2
The number is: 3
The number is: 4
The number is: 5
The number is: 6
The number is: 7
The number is: 8
The number is: 9
The number is: 10
Example 2 of for loop:-
 <!DOCTYPE html>
<html>
<body>
<?php
for ($i = 1; $i <= 10;
$i++)
{
$c=$i*2;
echo $c.”<br>”;
}
 Output:-
2
4
6
8
10
12
14
16
18
20
PHP while loop:-
 The while loop executes a block of code
as long as the specified condition is
true.
Syntax
while (condition is true)
{
code to be executed;
}
Example 1 of while loop:-
 !DOCTYPE html>
<html>
<body>
<?php
$a = 1;
while($a <= 5) {
echo $a “<br>";
$a++;
}
?>
</body>
</html>
Output:-
1
2
3
4
5
Example 2 of while loop:-
 DOCTYPE html>
<html>
<body>
<?php
$a = 1;
while($a <= 10) {
$c=$a*2;
echo $c “<br>";
$a++;
}
?>
</body>
</html>
 Output:-
2
4
6
8
10
12
14
16
18
20
PHP foreach loop:-
 The foreach loop works only on arrays, and is
used to loop through each key/value pair in an
array.
 Syntax:-
foreach(array name of variable as desired
variable)
{
Desired variable;
}
Example of foreach loop:-
 <!DOCTYPE html>
<html>
<body>
<?php
$colors
= array("red", "green", "b
lue", "yellow");
foreach ($colors as $valu
e) {
echo "$value <br>";
}
?>
</body>
</html>
Output:-
red
green
blue
yellow
PHP String:-
 strupper
 strlower
 strrev
 strlen
 substr
Example of strings:-
 <?php
$a=“rcew”;
echo strupper($c);
echo strlowerer($c);
echo strrev($c);
echo strlen($c);
?>
 Output:-
RCEW
rcew
wecr
4
Example of substring:-
<?php
$a=7062033739;
echo“xxxxxxx”.substr($a,7,3);
?>
Output:-
xxxxxxx739
PHP function:-
 include- It is used to include the file, if file is
not found then warning will be show and
script continue.
 require- It is used to include the file, But file
is not found in error will be show with
warning and screen stop.
 include_once-
.require_once-
. Implode- Implode is used to convert array
Into string.
. Explode- Explode is used to convert into
array.
PHP Array
 An array is a special variable, which can
hold more than one value at a time.
 Create an Array in PHP-
In PHP, the array( ) function is used to
create an array:
array( );
PHP Array function:-
 max:- find the largest value.
 min:-find the smallest value.
 array-sum:-means sum between two arrays.
 array-product:- means multiple.
 array-merge:- merge between two arrays.
 sort:-accending order.
 r-sort:-deccending order.
 array-pop:- delete last value.
 array push:-add value in last.
. array-shift:- delete first value.
. array-un shift:- add value in first
. print-r:- print the index and name
value first.
Example of max:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
echo max($arrr);
?>
 Output:-
600
Example of min:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
echo min($arrr);
?>
 Output:-
1
Example of sum:-
 <?php
$arrr=array(4,9,80,
95,300,1,600);
echo array
sum($arrr);
?>
 Output:-
1089
Example of product:-
 <?php
$arrr=array(4,9,80,
95,300,1,600);
echo
array_product($arr
r);
?>
 Output:-
49248000000
Example of merge:-
 <?php
$arrr=array(4,9,80,95,300
,1,600);
$arr=array(7,9,34,86,986,)
;
$ar=array_merge($arrr,$
arr);
foreach($ar as $d)
{
echo $d."<br>";
}
?>
 Output:-
4
9
80
95
300
1
600
7
9
34
86
986
Example of sort:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
sort($arrr);
foreach($arrr as $n)
{
echo $n."<br>";
}
?>
 Output:-
1
4
9
80
95
300
600
Example of rsort:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
rsort($arrr);
foreach($arrr as $d)
{
echo $d."<br>";
}
?>
 Output:-
600
300
95
80
9
4
1
Example of array_pop:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
array_pop($arrr);
foreach($arrr as $d)
{
echo $d."<br>";
}
?>
 Output:-
4
9
80
95
300
1
Example of array_push:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
array_push($arrr,111,1
21);
foreach($arrr as $d)
{
echo $d."<br>";
}
?>
Output:-
 4
9
80
95
300
1
600
111
121
Example of array_shift:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
array_shift($arrr);
foreach($arrr as $d)
{
echo $d."<br>";
}
?>
 Output:-
9
80
95
300
1
600
Example of array_unshift:-
 <?php
$arrr=array(4,9,80,95,
300,1,600);
array_unshift($arrr,00
,131);
foreach($arrr as $d)
{
echo $d."<br>";
}
?>
 Output:-
0
131
4
9
80
95
300
1
600
 <?php
$arrr=array(4,9,80,95,
300,1,600);
print_r($arrr);
foreach($arrr as $d)
{
echo $d."<br>";
}
?>
 Output:-
Array ( [0] => 4 [1] => 9 [2]
=> 80 [3] => 95 [4] => 300
[5] => 1 [6] => 600 ) 4
9
80
95
300
1
600

Más contenido relacionado

La actualidad más candente (20)

jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Php string function
Php string function Php string function
Php string function
 
Php basics
Php basicsPhp basics
Php basics
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Web Development using HTML & CSS
Web Development using HTML & CSSWeb Development using HTML & CSS
Web Development using HTML & CSS
 
Php forms
Php formsPhp forms
Php forms
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Javascript
JavascriptJavascript
Javascript
 
PHP - Introduction to PHP Forms
PHP - Introduction to PHP FormsPHP - Introduction to PHP Forms
PHP - Introduction to PHP Forms
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Javascript
JavascriptJavascript
Javascript
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 

Similar a Php.ppt

FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQLArti Parab Academics
 
Php by shivitomer
Php by shivitomerPhp by shivitomer
Php by shivitomerShivi Tomer
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPwahidullah mudaser
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Gheyath M. Othman
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaDeepak Rajput
 
What Is Php
What Is PhpWhat Is Php
What Is PhpAVC
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting languageElmer Concepcion Jr.
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Muhamad Al Imran
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_masterjeeva indra
 

Similar a Php.ppt (20)

FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 
Intro to php
Intro to phpIntro to php
Intro to php
 
PHP
PHPPHP
PHP
 
Php
PhpPhp
Php
 
Php by shivitomer
Php by shivitomerPhp by shivitomer
Php by shivitomer
 
PHP - Web Development
PHP - Web DevelopmentPHP - Web Development
PHP - Web Development
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in India
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
Php
PhpPhp
Php
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
Basic php 5
Basic php 5Basic php 5
Basic php 5
 
PHP-Part2
PHP-Part2PHP-Part2
PHP-Part2
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 

Último

Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Call Girls in Nagpur High Profile
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdftbatkhuu1
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...Call Girls in Nagpur High Profile
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...ranjana rawat
 
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...Pooja Nehwal
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentationamedia6
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵anilsa9823
 
Case Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneCase Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneLukeKholes
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)amitlee9823
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...babafaisel
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130Suhani Kapoor
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...Call Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Call Girls in Nagpur High Profile
 
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call GirlsCBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girlsmodelanjalisharma4
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxmirandajeremy200221
 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxjanettecruzeiro1
 
Fashion trends before and after covid.pptx
Fashion trends before and after covid.pptxFashion trends before and after covid.pptx
Fashion trends before and after covid.pptxVanshNarang19
 

Último (20)

Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
 
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentation
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
 
Case Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneCase Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, Pune
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call GirlsCBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptx
 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptx
 
Fashion trends before and after covid.pptx
Fashion trends before and after covid.pptxFashion trends before and after covid.pptx
Fashion trends before and after covid.pptx
 

Php.ppt

  • 2. Introduction to PHP:-  PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.  PHP stands for “PHP: Hypertext Preprocessor”.  Syntax based on Perl, Java , And C.  Very good for creating dynamic content.  PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.  Powerful, But somewhat risky!
  • 3. History:-  Started as a Perl hack in 1994 by Rasmus Lerdorf (to handle his resume), developed to PHP.  By 1997 up to PHP 3.0 with a new parser engine by Zee Suraski and Andi Gutamns.  Version 5.2.4 is current version, rewritten by Zend to include a no. of features, Such as an object model.  Current is version 5.
  • 4. How To Run Program In PHP:-  URL Open.  Server Must Be ON.  URL Address:- 127.0.0.1/folder name/file name or local host/folder name/filename
  • 5. PHP Scripts:-  Typically file ends in “.php”- -this is set by the web server configuration.  Separated in files with the <?php ?>.  PHP commands can make up an entire files, or can be contained in html- -this is a choice….  Program lines end in “ ; ” or we get an error.  Server recognizes embedded script and executes.  Result is passed to browser, Source isn’t visible.
  • 6. Example of PHP Script:-  <!DOCTYPE html> <html> <body> <?php echo "My first PHP script!"; ?> </body> </html> Output:- My first PHP script!
  • 7. String Print:-  “ ”  ‘ ’  ;  “ ‘ ’ ”  ‘ “ ” ’ Note:- If we want embed another language, like HTML in PHP then all HTML works as a string.
  • 8. PHP echo and print statements:-  echo and print are more or less the same. They are both used to output data to the screen.  The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.
  • 9. Example of echo statements:-  <!DOCTYPE html> <html> <body> <?php echo "<h2>PHP is Fun!</h2>"; echo "Hello world!<br>"; echo "I'm about to learn PHP!<br>"; echo "This ", "string ", "was ", "made ", "with multiple parameters."; ?> </body> </html>  Output:- PHP is Fun! Hello world! I'm about to learn PHP! This string was made with multiple parameters.
  • 10. Example of print statements:-  <!DOCTYPE html> <html> <body> <?php print "<h2>PHP is Fun!</h2>"; print "Hello world!<br>"; print "I'm about to learn PHP!"; ?> </body> </html>  Output:- PHP is Fun! Hello world! I'm about to learn PHP!
  • 11. PHP Variables:-  Rules for PHP variables: - A variable starts with the $ sign, followed by the name of the variable. - A variable name must start with a letter or the underscore character. - A variable name cannot start with a number. - A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ). - Variable names are case-sensitive ($age and $AGE are two different variables).
  • 12. PHP Data Types:-  Types of declaration of variable is known as Data Type.  PHP supports the following data types: - String -Integer -Float (floating point numbers - also called double) -Boolean -Array -Object -NULL -Resource
  • 13. PHP String:-  <!DOCTYPE html> <html> <body> <?php $x = "Hello world!"; $y = 'Hello world!”; echo $x; echo "<br>"; echo $y; ?> </body> </html>  Output:- Hello world! Hello world!
  • 14. PHP Integer:-  An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. *Rules for integers:  An integer must have at least one digit.  An integer must not have a decimal point.  An integer can be either positive or negative.  Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0).
  • 15. Example of PHP Integer:-  <!DOCTYPE html> <html> <body> <?php $x = 5985; var_dump($x); ?> </body> </html>  Output:- int(5985)
  • 16. Example PHP Float:-  <!DOCTYPE html> <html> <body> <?php $x = 10.365; var_dump($x); ?> </body> </html>  Output:- float(10.365)
  • 17. PHP Boolean:-  A Boolean represents two possible states: TRUE or FALSE.  $x = true; $y = false; Booleans are often used in conditional testing. You will learn more about conditional testing in a later chapter of this tutorial.
  • 18. PHP Arrays:-  An array stores multiple values in one single variable.  Example <?php $cars = array("Volvo","BMW","Toyota"); var_dump($cars); ?>  Output:- array(3) { [0]=> string(5) "Volvo" [1]=> string(3) "BMW" [2]=> string(6) "Toyota" }
  • 19. PHP Objects:-  An object is a data type which stores data and information on how to process that data.  In PHP, an object must be explicitly declared.  First we must declare a class of object. For this, we use the class keyword. A class is a structure that can contain properties and methods.
  • 20. PHP Null Value:-  Null is a special data type which can have only one value: NULL.  A variable of data type NULL is a variable that has no value assigned to it. Note: If a variable is created without a value, it is automatically assigned a value of NULL. Variables can also be emptied by setting the value to NULL:
  • 21. Example of PHP Null Value:-  <!DOCTYPE html> <html> <body> <?php $x = "Hello world!"; $x = null; var_dump($x); ?> </body> </html>  Output:- NULL
  • 22. PHP Operator:-  Operators are used to perform operations on variables and values. PHP divides the operators in the following groups:  Arithmetic operators. (For normal operations)  Assignment operators. ( = )  Relational operators. ( < , > , < = , = > )  Logical operators. ( and , or )
  • 23. PHP Conditional Statements:- In PHP we have the following conditional statements:  if statement - executes some code if one condition is true.  if...else statement - executes some code if a condition is true and another code if that condition is false.  if...elseif....else statement - executes different codes for more than two conditions  switch statement - selects one of many blocks of code to be executed.
  • 24. PHP- The If Statement:-  The if statement executes some code if one condition Is true.  Example Output:- <?php Have a good day! $t = date("H"); if ($t < "20") { echo "Have a good day!"; } ?>
  • 25. PHP- The If ... Else Statement:-  It executes some code if a condition is true and another code if that condition is false.  Example:- Output:- <?php $t = date("H"); Have a good day! if ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>
  • 26. PHP- The If .. Elseif..else Statement:-  The if....elseif...else statement executes different codes for more than two conditions.  Syntax if (condition) { code to be executed if this condition is true; } elseif (condition) { code to be executed if this condition is true; } else { code to be executed if all conditions are false; }
  • 27. Example If .. Elseif..else Statement:-  <?php Output:- $t = date("H"); if ($t < "10") { Have a good day! echo "HII!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>
  • 28. The PHP Switch Statement:-  “Use the switch statement to select one of many blocks of code to be executed”.  Example:- ?php $color = "red"; Output:- switch ($color) { case "red": Your color is red! echo "Your color is red!"; break; case "blue": echo "Your color is blue!"; break; case "green": echo "Your color is green!"; break; default: echo "Your color is neither red, blue, nor green!"; } ?>
  • 29. How To Get Form Value:- Super Global Variable  $_GET [‘ ’];  $_POST [‘ ’ ];  $_REQUEST_ [‘ ’];
  • 30. How To upload image on a server:-
  • 31. PHP Loop In PHP, we have the following looping statements:-  while - loops through a block of code as long as the specified condition is true.  do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true.  for - loops through a block of code a specified number of times.  foreach - loops through a block of code for each element in an array.
  • 32. PHP for loop:-  The for loop is used when you know in advance how many times the script should run. Parameters:  init counter: Initialize the loop counter value.  test counter: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.  increment counter: Increases the loop counter value.
  • 33. Example 1 of for loop:-  <!DOCTYPE html> <html> <body> <?php for ($x = 0; $x <= 10; $x++) { echo "The number is: $x <br>"; } ?> </body> </html>  Output:- The number is: 0 The number is: 1 The number is: 2 The number is: 3 The number is: 4 The number is: 5 The number is: 6 The number is: 7 The number is: 8 The number is: 9 The number is: 10
  • 34. Example 2 of for loop:-  <!DOCTYPE html> <html> <body> <?php for ($i = 1; $i <= 10; $i++) { $c=$i*2; echo $c.”<br>”; }  Output:- 2 4 6 8 10 12 14 16 18 20
  • 35. PHP while loop:-  The while loop executes a block of code as long as the specified condition is true. Syntax while (condition is true) { code to be executed; }
  • 36. Example 1 of while loop:-  !DOCTYPE html> <html> <body> <?php $a = 1; while($a <= 5) { echo $a “<br>"; $a++; } ?> </body> </html> Output:- 1 2 3 4 5
  • 37. Example 2 of while loop:-  DOCTYPE html> <html> <body> <?php $a = 1; while($a <= 10) { $c=$a*2; echo $c “<br>"; $a++; } ?> </body> </html>  Output:- 2 4 6 8 10 12 14 16 18 20
  • 38. PHP foreach loop:-  The foreach loop works only on arrays, and is used to loop through each key/value pair in an array.  Syntax:- foreach(array name of variable as desired variable) { Desired variable; }
  • 39. Example of foreach loop:-  <!DOCTYPE html> <html> <body> <?php $colors = array("red", "green", "b lue", "yellow"); foreach ($colors as $valu e) { echo "$value <br>"; } ?> </body> </html> Output:- red green blue yellow
  • 40. PHP String:-  strupper  strlower  strrev  strlen  substr
  • 41. Example of strings:-  <?php $a=“rcew”; echo strupper($c); echo strlowerer($c); echo strrev($c); echo strlen($c); ?>  Output:- RCEW rcew wecr 4
  • 43. PHP function:-  include- It is used to include the file, if file is not found then warning will be show and script continue.  require- It is used to include the file, But file is not found in error will be show with warning and screen stop.  include_once-
  • 44. .require_once- . Implode- Implode is used to convert array Into string. . Explode- Explode is used to convert into array.
  • 45. PHP Array  An array is a special variable, which can hold more than one value at a time.  Create an Array in PHP- In PHP, the array( ) function is used to create an array: array( );
  • 46. PHP Array function:-  max:- find the largest value.  min:-find the smallest value.  array-sum:-means sum between two arrays.  array-product:- means multiple.  array-merge:- merge between two arrays.  sort:-accending order.  r-sort:-deccending order.  array-pop:- delete last value.  array push:-add value in last.
  • 47. . array-shift:- delete first value. . array-un shift:- add value in first . print-r:- print the index and name value first.
  • 48. Example of max:-  <?php $arrr=array(4,9,80,95, 300,1,600); echo max($arrr); ?>  Output:- 600
  • 49. Example of min:-  <?php $arrr=array(4,9,80,95, 300,1,600); echo min($arrr); ?>  Output:- 1
  • 50. Example of sum:-  <?php $arrr=array(4,9,80, 95,300,1,600); echo array sum($arrr); ?>  Output:- 1089
  • 51. Example of product:-  <?php $arrr=array(4,9,80, 95,300,1,600); echo array_product($arr r); ?>  Output:- 49248000000
  • 52. Example of merge:-  <?php $arrr=array(4,9,80,95,300 ,1,600); $arr=array(7,9,34,86,986,) ; $ar=array_merge($arrr,$ arr); foreach($ar as $d) { echo $d."<br>"; } ?>  Output:- 4 9 80 95 300 1 600 7 9 34 86 986
  • 53. Example of sort:-  <?php $arrr=array(4,9,80,95, 300,1,600); sort($arrr); foreach($arrr as $n) { echo $n."<br>"; } ?>  Output:- 1 4 9 80 95 300 600
  • 54. Example of rsort:-  <?php $arrr=array(4,9,80,95, 300,1,600); rsort($arrr); foreach($arrr as $d) { echo $d."<br>"; } ?>  Output:- 600 300 95 80 9 4 1
  • 55. Example of array_pop:-  <?php $arrr=array(4,9,80,95, 300,1,600); array_pop($arrr); foreach($arrr as $d) { echo $d."<br>"; } ?>  Output:- 4 9 80 95 300 1
  • 56. Example of array_push:-  <?php $arrr=array(4,9,80,95, 300,1,600); array_push($arrr,111,1 21); foreach($arrr as $d) { echo $d."<br>"; } ?> Output:-  4 9 80 95 300 1 600 111 121
  • 57. Example of array_shift:-  <?php $arrr=array(4,9,80,95, 300,1,600); array_shift($arrr); foreach($arrr as $d) { echo $d."<br>"; } ?>  Output:- 9 80 95 300 1 600
  • 58. Example of array_unshift:-  <?php $arrr=array(4,9,80,95, 300,1,600); array_unshift($arrr,00 ,131); foreach($arrr as $d) { echo $d."<br>"; } ?>  Output:- 0 131 4 9 80 95 300 1 600
  • 59.  <?php $arrr=array(4,9,80,95, 300,1,600); print_r($arrr); foreach($arrr as $d) { echo $d."<br>"; } ?>  Output:- Array ( [0] => 4 [1] => 9 [2] => 80 [3] => 95 [4] => 300 [5] => 1 [6] => 600 ) 4 9 80 95 300 1 600