SlideShare a Scribd company logo
12 Marks
 Rasmus Lerdoff developed PHP in1994 and Released 1998.
 PHP is a recursive acronym of Hypertext Pre-Processor.
 In 1998 PHP3 was released
 In 2000 PHP4 –improved speed and reliability
 In 2004 PHP5 –Improved support for Object-Oriented Programming
 In 2006 PHP5.2 was released
 In 2009 PHP5.3 –Namespace Support
 In 2012 PHP5.4-Improved with Performance and memory Requirement.
 In 2013 PHP5.5-With Generators and finally blocks for exception
handling
 In 2014 PHP5.6-constatnt expression, character encoding etc.
 In 2015 PHP7.0-Return type Declaration, spaceship operator etc.
 In 2016 PHP7.1 –nullable types
 In 2017 PHP7.2- Abstract method overriding
 In 2018 PHP 7.3
 Latest version of PHP is PHP7.4 released in 2019 offers to build
applications that influence s everything form the website
 PHP is a Server-side Scripting Language and used to create dynamic web
pages.
 Speed
 Easy to Use/Simplicity
 Stable
 Platform Independent/Portability
 Open Source
 Built-in Database Connection Module
 Powerful Library Support
 Flexibility
 Database Connectivity
 Speed-UP Custom Web Application
Development
 PHP Script is executed on the server,and the
plain HTML result is sent back to the browser.
 PHP Script can be placed anywhere in the
document .
 PHP script starts with <?php And ends with
?>
<?php
//PHP Code goes here
?>
 <?php
 echo “hello world!”
 ?>
 Step 1 : Download the XAMPP Server From
internet
 Step 2: Install XAMPP Software
 Step 3: Open and Click on the start button
that is in front of Apache Text
 Step 4: Create PHP file in htdocs directory
which is resides in XAMPP
directory[c:sampphtdocs].
 Step 5:Save Program with extension .php in
htdocs direcory , then open your browser and
then type http://localhost/programname.php
on address bar and press Enter key.
 Variable:In PHP, a variable is declared using a $
sign followed by the variable name. Here, some
important points to know about variables:
 As PHP is a loosely typed language, so we do not
need to declare the data types of the variables. It
automatically analyzes the values and makes
conversions to its correct datatype.
 After declaring a variable, it can be reused
throughout the code.
 Assignment Operator (=) is used to assign the
value to a variable.
 A variable must start with a dollar ($) sign,
followed by the variable name.
 It can only contain alpha-numeric character and
underscore (A-z, 0-9, _).
 A variable name must start with a letter or
underscore (_) character.
 A PHP variable name cannot contain spaces.
 One thing to be kept in mind that the variable
name cannot start with a number or special
symbols.
 PHP variables are case-sensitive, so $name and
$NAME both are treated as different variable.
 Data Type:
In PHP is_int() or is_integer() are used to test whether a
value is an integer
For example,
<?php
$a=10;
if(is_int($a))
{
echo "is an integer";
}
?>
In PHP is_float() is used to test whether a value is a
floating point number
<?php
$a=10.91;
if(is_float($a))
{
echo "is an floating point number";
}
?>
In PHP is_string() is used to test whether a value is a
String
For example 1,
<?php
$a="good";
if(is_string($a))
{
echo "is an string";
}
?>
For example 2,
<?php
$a="Good";
echo "$a morning";
?>
 <?php
 $a=true;
 if(is_bool($a))
 {
 echo "is an boolean";
 }
 ?>
 Numeric array − An array with a numeric index.
Values are stored and accessed in linear fashion.
 Associative array − An array with strings as index.
This stores element values in association with key
values rather than in a strict linear index order.
 Multidimensional array − An array containing one
or more arrays and values are accessed using multiple
indices
<?php
/* First method to create array. */
$numbers = array( 1, 2, 3, 4, 5);
foreach( $numbers as $value )
{ echo "Value is $value <br />"; }
/* Second method to create array. */
$numbers[0] = "one";
$numbers[1] = "two";
$numbers[2] = "three";
$numbers[3] = "four";
$numbers[4] = "five";
foreach( $numbers as $value )
{
echo "Value is $value <br />";
}
?>
<?php
/* First method to associate create array. */
$salaries = array("mohammad" => 2000, "qadir" => 1000, "zara" => 500);
echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />";
echo "Salary of qadir is ". $salaries['qadir']. "<br />";
echo "Salary of zara is ". $salaries['zara']. "<br />";
/* Second method to create array. */
$salaries['mohammad'] = "high";
$salaries['qadir'] = "medium";
$salaries['zara'] = "low";
echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />";
echo "Salary of qadir is ". $salaries['qadir']. "<br />";
echo "Salary of zara is ". $salaries['zara']. "<br />";
?>
<?php
$marks = array("mohammad" =>
array ( "physics" => 35,
"maths" => 30,
"chemistry" => 39),
"qadir" => array ("physics" => 30,
"maths" => 32,
"chemistry" => 29),
"zara" => array ("physics" => 31,
"maths" => 22,
"chemistry" => 39)
);
/* Accessing multi-dimensional array values */
echo "Marks for mohammad in physics : " ;
echo $marks['mohammad']['physics'] . "<br />";
echo "Marks for qadir in maths : ";
echo $marks['qadir']['maths'] . "<br />";
echo "Marks for zara in chemistry : " ;
echo $marks['zara']['chemistry'] . "<br />";
?>
Multidimensional
array
 In PHP, Object is a compound data type
(along with arrays). Values of more than one
types can be stored together in a single
variable. Object is an instance of either a
built-in or user defined class. In addition to
properties, class defines functionality
associated with data.
<?php
class SayHello
{
function hello()
{ echo "Hello World";
}
}
$obj=new SayHello;
$obj->hello();
?>
 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. Tip: If a variable is created without a
value, it is automatically assigned a value of
NULL.
 Resources: The special resource type is not
an actual data type. It is the storing of a
reference to functions and resources external
to PHP. A common example of using the
resource data type is a database call.
 The if Statement
 Executes some code if one condition is true
 Syntax
 if (condition) {
code to be executed if condition is true;
}
<?php
$t = date("H");
if ($t < "20")
{
echo "Have a good day!";
}
?>
 The if...else Statement
 The if...else statement executes some code if a
condition is true and another code if that condition is
false
 Syntax
 if (condition) {
code to be executed if condition is true;
} else {
code to be executed if condition is false;
}
 <?php
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
 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 first condition is false and this
condition is true;
} else {
code to be executed if all conditions are false;
}
 <?php
$t = date("H");
if ($t < "10") {
echo "Have a good morning!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
 The switch Statement
 The switch statement is used to perform different
actions based on different conditions.
 Syntax
 switch (n) {
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
case label3:
code to be executed if n=label3;
break;
...
default:
code to be executed if n is different from all
labels;
}
 <?php
$favcolor = "red";
switch ($favcolor) {
case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red,
blue, nor green!";
}
?>
 Break Statement
 <?php
 $i = 0;
 for ($i = 0;$i <= 5;$i++)
 { if ($i==2)
 {
 break;
 }
 echo $i;
 echo "<br />";
 }
 echo "End of for loop" ;
 ?>
 Continue statement
 <?php
 $i = 0;
 for ($i = 0;$i <= 5;$i++)
 {
 if ($i==2)
 {
 continue;
 }
 echo $i;
 echo "<br />";
 }
 echo "End of for loop" ;
 ?>
 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;
}
<?php
$x = 1;
while($x <= 5) {
echo "The number is: $x <br>";
$x++;
}
?>
 do...while Loop
 The do...while loop will always execute the block of
code once, it will then check the condition, and
repeat the loop while the specified condition is
true.
 Syntax
 do {
code to be executed;
} while (condition is true);
 <?php
$x = 1;
do {
echo "The number is: $x <br>";
$x++;
} while ($x <= 5);
?>
 For Loop
 The for loop is used when you know in advance how
many tim
 Syntax
 for (init counter; test counter; increment counter) {
code to be executed for each iteration;
}
 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
<?php
for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x <br>";
}
?>
 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 as $value) {
code to be executed;
}
 For every loop iteration, the value of the current
array element is assigned to $value and the array
pointer is moved by one, until it reaches the last
array element.
 <?php
$colors = array("red", "green", "blue", "yellow");
foreach ($colors as $value) {
echo "$value <br>";
}
?>
 <?php
 $a="hello";
 $m=var_dump($a);
 echo $m;
 ?>
 Type Juggling means dealing with a variable
type. In PHP a variables type is determined by
the context in which it is used. If an integer
value is assigned to a variable, it becomes an
integer.
 approach of PHP to deal with dynamically
changing value of variable is called type
juggling
 <?php
 $a=10;
 echo var_dump($a);
 echo"<br>";
 $b="10";
 echo gettype($b);
 echo"<br>";
 echo $c=$a+$b;
 echo"<br>";
 echo var_dump($c);
 ?>
 Exprression are any code that evaluates value
 An expression is a piece of code that
evaluates to a value.
 For eg,
 $x=$a+$b
 An Operator is a symbol that manipulates one
or more values ,usually producing a new
value in the process.
 Unary Operator
 Binary Operator
 Conditional Operator(Ternary Operator)
1. Arithmetic Operators
2. Autoincrement and Autodecrement Operator
3. Comparison Operaor
4. Logical Operators
5. Assignment Operators
6. Bitwise Operators
 7. Casting Operators
 Casting operator changes type of its operand
by force.
 For eg
<?php
$a="5";
echo var_dump($a);
$b=(int) $a;
echo var_dump($b);
?>
 8.Miscellanous operator
 Error Supression (@) Operator-
 In PHP @ symbol is defined as Error Control
Operator. When it is prefixed to any
expression, any error encountered by PHP
parser while executing it will be suppressed
and the expression will be ignored.
 <?php
 @$value=1/0;
 echo "Hello";
 ?>
 Execution
 PHP Supports one execution operator
backticks(``).
 PHP will attempt to execute the contents of
the backticks as a shellcommand
 Eg.
 $output=`ls -l`;
 Echo $output;
 Conditional
 (?:)
Syntax-exp1 ? Exp2 : exp3;
unit 1.pptx

More Related Content

Similar to unit 1.pptx

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
prabhatjon
 
PHP MATERIAL
PHP MATERIALPHP MATERIAL
PHP MATERIAL
zatax
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
Ian Macali
 
What Is Php
What Is PhpWhat Is Php
What Is Php
AVC
 
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
Deepak Rajput
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
Khem Puthea
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
Php introduction
Php introductionPhp introduction
Php introduction
Pratik Patel
 
php&mysql with Ethical Hacking
php&mysql with Ethical Hackingphp&mysql with Ethical Hacking
php&mysql with Ethical Hacking
BCET
 
Php
PhpPhp
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
IIUM
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
pkaviya
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
HambardeAtharva
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Muthuganesh S
 
php41.ppt
php41.pptphp41.ppt
php41.ppt
Nishant804733
 

Similar to unit 1.pptx (20)

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP MATERIAL
PHP MATERIALPHP MATERIAL
PHP MATERIAL
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
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
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Php Learning show
Php Learning showPhp Learning show
Php Learning show
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
php&mysql with Ethical Hacking
php&mysql with Ethical Hackingphp&mysql with Ethical Hacking
php&mysql with Ethical Hacking
 
Php
PhpPhp
Php
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
 
Php essentials
Php essentialsPhp essentials
Php essentials
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdfIT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
IT2255 Web Essentials - Unit IV Server-Side Processing and Scripting - PHP.pdf
 
WT_PHP_PART1.pdf
WT_PHP_PART1.pdfWT_PHP_PART1.pdf
WT_PHP_PART1.pdf
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
php41.ppt
php41.pptphp41.ppt
php41.ppt
 

Recently uploaded

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

unit 1.pptx

  • 2.  Rasmus Lerdoff developed PHP in1994 and Released 1998.  PHP is a recursive acronym of Hypertext Pre-Processor.  In 1998 PHP3 was released  In 2000 PHP4 –improved speed and reliability  In 2004 PHP5 –Improved support for Object-Oriented Programming  In 2006 PHP5.2 was released  In 2009 PHP5.3 –Namespace Support  In 2012 PHP5.4-Improved with Performance and memory Requirement.  In 2013 PHP5.5-With Generators and finally blocks for exception handling  In 2014 PHP5.6-constatnt expression, character encoding etc.  In 2015 PHP7.0-Return type Declaration, spaceship operator etc.  In 2016 PHP7.1 –nullable types  In 2017 PHP7.2- Abstract method overriding  In 2018 PHP 7.3  Latest version of PHP is PHP7.4 released in 2019 offers to build applications that influence s everything form the website  PHP is a Server-side Scripting Language and used to create dynamic web pages.
  • 3.  Speed  Easy to Use/Simplicity  Stable  Platform Independent/Portability  Open Source  Built-in Database Connection Module  Powerful Library Support  Flexibility  Database Connectivity  Speed-UP Custom Web Application Development
  • 4.  PHP Script is executed on the server,and the plain HTML result is sent back to the browser.  PHP Script can be placed anywhere in the document .  PHP script starts with <?php And ends with ?> <?php //PHP Code goes here ?>
  • 5.  <?php  echo “hello world!”  ?>
  • 6.  Step 1 : Download the XAMPP Server From internet  Step 2: Install XAMPP Software  Step 3: Open and Click on the start button that is in front of Apache Text
  • 7.  Step 4: Create PHP file in htdocs directory which is resides in XAMPP directory[c:sampphtdocs].
  • 8.  Step 5:Save Program with extension .php in htdocs direcory , then open your browser and then type http://localhost/programname.php on address bar and press Enter key.
  • 9.  Variable:In PHP, a variable is declared using a $ sign followed by the variable name. Here, some important points to know about variables:  As PHP is a loosely typed language, so we do not need to declare the data types of the variables. It automatically analyzes the values and makes conversions to its correct datatype.  After declaring a variable, it can be reused throughout the code.  Assignment Operator (=) is used to assign the value to a variable.
  • 10.  A variable must start with a dollar ($) sign, followed by the variable name.  It can only contain alpha-numeric character and underscore (A-z, 0-9, _).  A variable name must start with a letter or underscore (_) character.  A PHP variable name cannot contain spaces.  One thing to be kept in mind that the variable name cannot start with a number or special symbols.  PHP variables are case-sensitive, so $name and $NAME both are treated as different variable.
  • 12. In PHP is_int() or is_integer() are used to test whether a value is an integer For example, <?php $a=10; if(is_int($a)) { echo "is an integer"; } ?>
  • 13. In PHP is_float() is used to test whether a value is a floating point number <?php $a=10.91; if(is_float($a)) { echo "is an floating point number"; } ?>
  • 14. In PHP is_string() is used to test whether a value is a String For example 1, <?php $a="good"; if(is_string($a)) { echo "is an string"; } ?> For example 2, <?php $a="Good"; echo "$a morning"; ?>
  • 15.  <?php  $a=true;  if(is_bool($a))  {  echo "is an boolean";  }  ?>
  • 16.  Numeric array − An array with a numeric index. Values are stored and accessed in linear fashion.  Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.  Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices
  • 17. <?php /* First method to create array. */ $numbers = array( 1, 2, 3, 4, 5); foreach( $numbers as $value ) { echo "Value is $value <br />"; } /* Second method to create array. */ $numbers[0] = "one"; $numbers[1] = "two"; $numbers[2] = "three"; $numbers[3] = "four"; $numbers[4] = "five"; foreach( $numbers as $value ) { echo "Value is $value <br />"; } ?>
  • 18. <?php /* First method to associate create array. */ $salaries = array("mohammad" => 2000, "qadir" => 1000, "zara" => 500); echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />"; echo "Salary of qadir is ". $salaries['qadir']. "<br />"; echo "Salary of zara is ". $salaries['zara']. "<br />"; /* Second method to create array. */ $salaries['mohammad'] = "high"; $salaries['qadir'] = "medium"; $salaries['zara'] = "low"; echo "Salary of mohammad is ". $salaries['mohammad'] . "<br />"; echo "Salary of qadir is ". $salaries['qadir']. "<br />"; echo "Salary of zara is ". $salaries['zara']. "<br />"; ?>
  • 19. <?php $marks = array("mohammad" => array ( "physics" => 35, "maths" => 30, "chemistry" => 39), "qadir" => array ("physics" => 30, "maths" => 32, "chemistry" => 29), "zara" => array ("physics" => 31, "maths" => 22, "chemistry" => 39) ); /* Accessing multi-dimensional array values */ echo "Marks for mohammad in physics : " ; echo $marks['mohammad']['physics'] . "<br />"; echo "Marks for qadir in maths : "; echo $marks['qadir']['maths'] . "<br />"; echo "Marks for zara in chemistry : " ; echo $marks['zara']['chemistry'] . "<br />"; ?> Multidimensional array
  • 20.  In PHP, Object is a compound data type (along with arrays). Values of more than one types can be stored together in a single variable. Object is an instance of either a built-in or user defined class. In addition to properties, class defines functionality associated with data.
  • 21. <?php class SayHello { function hello() { echo "Hello World"; } } $obj=new SayHello; $obj->hello(); ?>
  • 22.  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. Tip: If a variable is created without a value, it is automatically assigned a value of NULL.  Resources: The special resource type is not an actual data type. It is the storing of a reference to functions and resources external to PHP. A common example of using the resource data type is a database call.
  • 23.  The if Statement  Executes some code if one condition is true  Syntax  if (condition) { code to be executed if condition is true; } <?php $t = date("H"); if ($t < "20") { echo "Have a good day!"; } ?>
  • 24.  The if...else Statement  The if...else statement executes some code if a condition is true and another code if that condition is false  Syntax  if (condition) { code to be executed if condition is true; } else { code to be executed if condition is false; }  <?php $t = date("H"); if ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>
  • 25.  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 first condition is false and this condition is true; } else { code to be executed if all conditions are false; }  <?php $t = date("H"); if ($t < "10") { echo "Have a good morning!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>
  • 26.  The switch Statement  The switch statement is used to perform different actions based on different conditions.  Syntax  switch (n) { case label1: code to be executed if n=label1; break; case label2: code to be executed if n=label2; break; case label3: code to be executed if n=label3; break; ... default: code to be executed if n is different from all labels; }
  • 27.  <?php $favcolor = "red"; switch ($favcolor) { case "red": echo "Your favorite color is red!"; break; case "blue": echo "Your favorite color is blue!"; break; case "green": echo "Your favorite color is green!"; break; default: echo "Your favorite color is neither red, blue, nor green!"; } ?>
  • 28.  Break Statement  <?php  $i = 0;  for ($i = 0;$i <= 5;$i++)  { if ($i==2)  {  break;  }  echo $i;  echo "<br />";  }  echo "End of for loop" ;  ?>
  • 29.  Continue statement  <?php  $i = 0;  for ($i = 0;$i <= 5;$i++)  {  if ($i==2)  {  continue;  }  echo $i;  echo "<br />";  }  echo "End of for loop" ;  ?>
  • 30.  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; } <?php $x = 1; while($x <= 5) { echo "The number is: $x <br>"; $x++; } ?>
  • 31.  do...while Loop  The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.  Syntax  do { code to be executed; } while (condition is true);  <?php $x = 1; do { echo "The number is: $x <br>"; $x++; } while ($x <= 5); ?>
  • 32.  For Loop  The for loop is used when you know in advance how many tim  Syntax  for (init counter; test counter; increment counter) { code to be executed for each iteration; }  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 <?php for ($x = 0; $x <= 10; $x++) { echo "The number is: $x <br>"; } ?>
  • 33.  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 as $value) { code to be executed; }  For every loop iteration, the value of the current array element is assigned to $value and the array pointer is moved by one, until it reaches the last array element.  <?php $colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) { echo "$value <br>"; } ?>
  • 34.  <?php  $a="hello";  $m=var_dump($a);  echo $m;  ?>
  • 35.  Type Juggling means dealing with a variable type. In PHP a variables type is determined by the context in which it is used. If an integer value is assigned to a variable, it becomes an integer.  approach of PHP to deal with dynamically changing value of variable is called type juggling
  • 36.  <?php  $a=10;  echo var_dump($a);  echo"<br>";  $b="10";  echo gettype($b);  echo"<br>";  echo $c=$a+$b;  echo"<br>";  echo var_dump($c);  ?>
  • 37.  Exprression are any code that evaluates value  An expression is a piece of code that evaluates to a value.  For eg,  $x=$a+$b
  • 38.  An Operator is a symbol that manipulates one or more values ,usually producing a new value in the process.  Unary Operator  Binary Operator  Conditional Operator(Ternary Operator)
  • 39. 1. Arithmetic Operators 2. Autoincrement and Autodecrement Operator 3. Comparison Operaor 4. Logical Operators 5. Assignment Operators 6. Bitwise Operators
  • 40.  7. Casting Operators  Casting operator changes type of its operand by force.  For eg <?php $a="5"; echo var_dump($a); $b=(int) $a; echo var_dump($b); ?>
  • 41.  8.Miscellanous operator  Error Supression (@) Operator-  In PHP @ symbol is defined as Error Control Operator. When it is prefixed to any expression, any error encountered by PHP parser while executing it will be suppressed and the expression will be ignored.
  • 42.  <?php  @$value=1/0;  echo "Hello";  ?>
  • 43.  Execution  PHP Supports one execution operator backticks(``).  PHP will attempt to execute the contents of the backticks as a shellcommand  Eg.  $output=`ls -l`;  Echo $output;