SlideShare a Scribd company logo
Introduction To PHPIntroduction To PHP
ContentsContents
• IntroductionIntroduction
• Environmental SetupEnvironmental Setup
• Syntax OverviewSyntax Overview
• Variable typesVariable types
• OperatorsOperators
• Decision makingDecision making
• Looping statementsLooping statements
• ArraysArrays
• StringsStrings
• Get and postGet and post
• Database (MYSQL)Database (MYSQL)
IntroductionIntroduction
The PHP Hypertext Preprocessor (PHP) is a programming language that
allows web developers to create dynamic content that interacts with
databases. PHP is basically used for developing web based software
applications.
<html>
<head>
<title>PHP Script Execution</title>
</head>
<body>
<?php echo "<h1>Hello, PHP!</h1>";
?>
</body>
</html>
Environmental SetupEnvironmental Setup
• Web Server (WAMP)
• Database (MYSQL)
• PHP Editor (Dreamviewer ,sublime, notepad++)
Syntax OverviewSyntax Overview
•Canonical PHP tagsCanonical PHP tags
<?php...
?>
• Commenting PHP CodeCommenting PHP Code
Single-line comments − They are generally used for short explanations or notes
relevant to the local code. Here are the examples of single line comments.
<?
// This is a comment too. Each style comments only
print "An example with single line comments"; ?>
•Multi-lines commentsMulti-lines comments
<? /* This is a comment with multiline Author : Mohammad Mohtashim Purpose:
Multiline Comments Demo Subject: PHP */
print "An example with multi line comments"; ?>
PHP is case sensitivePHP is case sensitive
<html>
<body>
<?php
$capital = 67;
print("Variable capital is $capital<br>");
print("Variable CaPiTaL is $CaPiTaL<br>");
?>
</body>
</html>
Variable typesVariable types
• All variables in PHP are denoted with a leading dollar sign ($).
• PHP variables are Perl-like,C Language .
 Integers − are whole numbers, without a decimal point, like 4195.
 Doubles − are floating-point numbers, like 3.14159 or 49.1.
 Booleans − have only two possible values either true or false.
 NULL − is a special type that only has one value: NULL.
 Strings − are sequences of characters, like 'PHP supports string
operations.‘
 Arrays − are named and indexed collections of other values.
ExampleExample
• $int_var = 12345;
• $another_int = -12345 + 12345;
<?php
$many = 2.2888800;
$many_2 = 2.2111200;
$few = $many + $many_2;
print("$many + $many_2 = $few <br>");
?>
OperatorsOperators
• Arithmetic OperatorsArithmetic Operators
• Assignment OperatorsAssignment Operators
• Comparison OperatorsComparison Operators
• Logical (or Relational) OperatorsLogical (or Relational) Operators
ExamplesExamples
Arithmetic OperatorsArithmetic Operators
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x + $y;
?>
</body>
</html>
Assignment OperatorsAssignment Operators
<!DOCTYPE html>
<html>
<body>
<?php
$x = 50;
$x -= 30;
echo $x;
?>
</body>
</html>
Comparison OperatorsComparison Operators
<!DOCTYPE html>
<html>
<body>
<?php
$x = 50;
$y = 50;
var_dump($x >= $y);
?>
</body>
</html>
Logical (or Relational) OperatorsLogical (or Relational) Operators
ExampleExample
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = 50;
if ($x == 100 && $y == 50) {
echo "Hello world!";
}
?>
</body>
</html>
Decision makingDecision making
IF Statements(Syntax)IF Statements(Syntax)
<html>
<body>
<?php
$d = date("D");
if ($d == "Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!"; ?>
</body>
</html>
ElseIf StatementElseIf Statement
<html>
<body>
<?php
$d = date("D");
if ($d == "Fri")
echo "Have a nice weekend!";
else if ($d == "Sun")
echo "Have a nice Sunday!";
else echo "Have a nice day!"; ?>
</body>
</html>
The Switch StatementThe Switch Statement
Looping statementsLooping statements
The for loop statementThe for loop statement
<?php
$a = 0; $b = 0;
for( $i = 0; $i<5; $i++ )
{
$a += 10; $b += 5;
}
echo ("At the end of the loop a = $a and b = $b" );
?>
The while loop statementThe while loop statement
<?php
$i = 0;
$num = 50;
while( $i < 10)
{
$num--;
$i++;
}
echo ("Loop stopped at i = $i and num = $num" );
?>
The do...while loop statementThe do...while loop statement
<?php
$i = 0;
$num = 0;
do
{
$i++;
} while( $i < 10 );
echo ("Loop stopped at i = $i" );
?>
The break statementThe break statement
Example
<?php
$i = 0;
while( $i < 10)
{
$i++;
if( $i == 3 )break;
}
echo ("Loop stopped at i = $i" );
?>
ArraysArrays
An array is a data structure that stores one or more similar type of values
in a single value
•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
•Multidimensional array − An array containing one or more arrays and
values are accessed using multiple indices a strict linear index order.
ExampleExample
StringsStrings
String Concatenation OperatorString Concatenation Operator
<?php
$string1="Hello World";
$string2="1234";
echo $string1 . " " . $string2;
?>
Using the strlen() functionUsing the strlen() function
<?php echo strlen("Hello world!"); ?>
Get and postGet and post
GET METHODGET METHOD
The GET method sends the encoded user information appended to the
page request. The page and the encoded information are separated by
the ?character.
•Never use GET method if you have password or other sensitive
information to be sent to the server.
•GET can't be used to send binary data, like images or word documents, to
the server.
•The GET method is restricted to send upto 1024 characters only.
<?php
if( $_GET["name"] || $_GET["age"] ) {
echo "Welcome ". $_GET['name']. "<br />";
echo "You are ". $_GET['age']. " years old.";
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "age" />
<input type = "submit" />
</form>
</body>
</html>
The POST MethodThe POST Method
•The POST method does not have any restriction on data size to be sent.
•The POST method can be used to send ASCII as well as binary data.
•The data sent by POST method goes through HTTP header so security
depends on HTTP protocol. By using Secure HTTP you can make sure that
your information is secure.
Database (MYSQL)
• DDL
• DML
• Queries
• Assignments on DDL and DML
• Wamp server installation
THANK YOUTHANK YOU

More Related Content

PPTX
PPT
Php with MYSQL Database
PPT
PHP - Introduction to PHP AJAX
PDF
Javascript basics
PPTX
PHP Presentation
PDF
Introduction to PHP - Basics of PHP
PPTX
PPT
Java Script ppt
Php with MYSQL Database
PHP - Introduction to PHP AJAX
Javascript basics
PHP Presentation
Introduction to PHP - Basics of PHP
Java Script ppt

What's hot (20)

PPT
Asynchronous JavaScript & XML (AJAX)
PPTX
New Elements & Features in HTML5
PDF
jQuery for beginners
PPT
Javascript
PPT
01 Php Introduction
PDF
JavaScript - Chapter 8 - Objects
PDF
Chap 4 PHP.pdf
PDF
HTML and CSS crash course!
PPT
Php Error Handling
PPTX
Javascript
PPTX
PPTX
Java script
PPTX
Spring boot
PPT
Java Persistence API (JPA) Step By Step
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
PDF
JavaScript Programming
Asynchronous JavaScript & XML (AJAX)
New Elements & Features in HTML5
jQuery for beginners
Javascript
01 Php Introduction
JavaScript - Chapter 8 - Objects
Chap 4 PHP.pdf
HTML and CSS crash course!
Php Error Handling
Javascript
Java script
Spring boot
Java Persistence API (JPA) Step By Step
FYBSC IT Web Programming Unit IV PHP and MySQL
JavaScript Programming
Ad

Viewers also liked (20)

PPT
Php Presentation
PPT
Introduction to PHP
PPT
Php Ppt
PDF
Introduction to PHP
PPTX
Introduction to PHP
PDF
Introduction to php
PPTX
Ch1(introduction to php)
PPT
PHP - Introduction to PHP
PPT
Beginners PHP Tutorial
PPTX
PHP Summer Training Presentation
PPT
Open Source Package PHP & MySQL
PPT
Oops in PHP
PPTX
PHP Powerpoint -- Teach PHP with this
PPT
PDF
VT17 - DA287A - Kursintroduktion
PPT
Php i-slides
PPTX
learning html
PDF
cake phptutorial
PDF
Php a dynamic web scripting language
Php Presentation
Introduction to PHP
Php Ppt
Introduction to PHP
Introduction to PHP
Introduction to php
Ch1(introduction to php)
PHP - Introduction to PHP
Beginners PHP Tutorial
PHP Summer Training Presentation
Open Source Package PHP & MySQL
Oops in PHP
PHP Powerpoint -- Teach PHP with this
VT17 - DA287A - Kursintroduktion
Php i-slides
learning html
cake phptutorial
Php a dynamic web scripting language
Ad

Similar to Introduction To PHP (20)

PPT
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
PPT
Php i basic chapter 3
PPT
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
PDF
WEB-MODULE 4.pdf
PPT
PHP complete reference with database concepts for beginners
PDF
Hsc IT 5. Server-Side Scripting (PHP).pdf
PPTX
Lecture 6: Introduction to PHP and Mysql .pptx
PPT
php 1
PPTX
Php reports sumit
PDF
PHP Arrays - indexed and associative array.
PPTX
Lecture 9 - Intruduction to BOOTSTRAP.pptx
PPT
PPTX
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
PPT
LAB PHP Consolidated.ppt
PPTX
PHP FUNCTIONS
PPT
Php introduction with history of php
PPT
php fundamental
PPT
PPT
Php training100%placement-in-mumbai
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
WEB-MODULE 4.pdf
PHP complete reference with database concepts for beginners
Hsc IT 5. Server-Side Scripting (PHP).pdf
Lecture 6: Introduction to PHP and Mysql .pptx
php 1
Php reports sumit
PHP Arrays - indexed and associative array.
Lecture 9 - Intruduction to BOOTSTRAP.pptx
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
LAB PHP Consolidated.ppt
PHP FUNCTIONS
Php introduction with history of php
php fundamental
Php training100%placement-in-mumbai

Recently uploaded (20)

PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PDF
Types of Literary Text: Poetry and Prose
PDF
Landforms and landscapes data surprise preview
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
PPTX
How to Manage Bill Control Policy in Odoo 18
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PPTX
ACUTE NASOPHARYNGITIS. pptx
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
PPTX
Congenital Hypothyroidism pptx
PPTX
Strengthening open access through collaboration: building connections with OP...
PPTX
Introduction and Scope of Bichemistry.pptx
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
Types of Literary Text: Poetry and Prose
Landforms and landscapes data surprise preview
NOI Hackathon - Summer Edition - GreenThumber.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Loyalty Points in Odoo 18 Sales
Information Texts_Infographic on Forgetting Curve.pptx
Skill Development Program For Physiotherapy Students by SRY.pptx
How to Manage Bill Control Policy in Odoo 18
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
ACUTE NASOPHARYNGITIS. pptx
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
The Final Stretch: How to Release a Game and Not Die in the Process.
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
Congenital Hypothyroidism pptx
Strengthening open access through collaboration: building connections with OP...
Introduction and Scope of Bichemistry.pptx

Introduction To PHP

  • 2. ContentsContents • IntroductionIntroduction • Environmental SetupEnvironmental Setup • Syntax OverviewSyntax Overview • Variable typesVariable types • OperatorsOperators • Decision makingDecision making • Looping statementsLooping statements • ArraysArrays • StringsStrings • Get and postGet and post • Database (MYSQL)Database (MYSQL)
  • 3. IntroductionIntroduction The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. <html> <head> <title>PHP Script Execution</title> </head> <body> <?php echo "<h1>Hello, PHP!</h1>"; ?> </body> </html>
  • 4. Environmental SetupEnvironmental Setup • Web Server (WAMP) • Database (MYSQL) • PHP Editor (Dreamviewer ,sublime, notepad++)
  • 5. Syntax OverviewSyntax Overview •Canonical PHP tagsCanonical PHP tags <?php... ?> • Commenting PHP CodeCommenting PHP Code Single-line comments − They are generally used for short explanations or notes relevant to the local code. Here are the examples of single line comments. <? // This is a comment too. Each style comments only print "An example with single line comments"; ?> •Multi-lines commentsMulti-lines comments <? /* This is a comment with multiline Author : Mohammad Mohtashim Purpose: Multiline Comments Demo Subject: PHP */ print "An example with multi line comments"; ?>
  • 6. PHP is case sensitivePHP is case sensitive <html> <body> <?php $capital = 67; print("Variable capital is $capital<br>"); print("Variable CaPiTaL is $CaPiTaL<br>"); ?> </body> </html>
  • 7. Variable typesVariable types • All variables in PHP are denoted with a leading dollar sign ($). • PHP variables are Perl-like,C Language .  Integers − are whole numbers, without a decimal point, like 4195.  Doubles − are floating-point numbers, like 3.14159 or 49.1.  Booleans − have only two possible values either true or false.  NULL − is a special type that only has one value: NULL.  Strings − are sequences of characters, like 'PHP supports string operations.‘  Arrays − are named and indexed collections of other values.
  • 8. ExampleExample • $int_var = 12345; • $another_int = -12345 + 12345; <?php $many = 2.2888800; $many_2 = 2.2111200; $few = $many + $many_2; print("$many + $many_2 = $few <br>"); ?>
  • 9. OperatorsOperators • Arithmetic OperatorsArithmetic Operators • Assignment OperatorsAssignment Operators • Comparison OperatorsComparison Operators • Logical (or Relational) OperatorsLogical (or Relational) Operators
  • 10. ExamplesExamples Arithmetic OperatorsArithmetic Operators <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 6; echo $x + $y; ?> </body> </html>
  • 11. Assignment OperatorsAssignment Operators <!DOCTYPE html> <html> <body> <?php $x = 50; $x -= 30; echo $x; ?> </body> </html>
  • 13. <!DOCTYPE html> <html> <body> <?php $x = 50; $y = 50; var_dump($x >= $y); ?> </body> </html>
  • 14. Logical (or Relational) OperatorsLogical (or Relational) Operators
  • 15. ExampleExample <!DOCTYPE html> <html> <body> <?php $x = 100; $y = 50; if ($x == 100 && $y == 50) { echo "Hello world!"; } ?> </body> </html>
  • 16. Decision makingDecision making IF Statements(Syntax)IF Statements(Syntax) <html> <body> <?php $d = date("D"); if ($d == "Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?> </body> </html>
  • 17. ElseIf StatementElseIf Statement <html> <body> <?php $d = date("D"); if ($d == "Fri") echo "Have a nice weekend!"; else if ($d == "Sun") echo "Have a nice Sunday!"; else echo "Have a nice day!"; ?> </body> </html>
  • 18. The Switch StatementThe Switch Statement
  • 19. Looping statementsLooping statements The for loop statementThe for loop statement <?php $a = 0; $b = 0; for( $i = 0; $i<5; $i++ ) { $a += 10; $b += 5; } echo ("At the end of the loop a = $a and b = $b" ); ?>
  • 20. The while loop statementThe while loop statement <?php $i = 0; $num = 50; while( $i < 10) { $num--; $i++; } echo ("Loop stopped at i = $i and num = $num" ); ?>
  • 21. The do...while loop statementThe do...while loop statement <?php $i = 0; $num = 0; do { $i++; } while( $i < 10 ); echo ("Loop stopped at i = $i" ); ?>
  • 22. The break statementThe break statement
  • 23. Example <?php $i = 0; while( $i < 10) { $i++; if( $i == 3 )break; } echo ("Loop stopped at i = $i" ); ?>
  • 24. ArraysArrays An array is a data structure that stores one or more similar type of values in a single value •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 •Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices a strict linear index order.
  • 26. StringsStrings String Concatenation OperatorString Concatenation Operator <?php $string1="Hello World"; $string2="1234"; echo $string1 . " " . $string2; ?> Using the strlen() functionUsing the strlen() function <?php echo strlen("Hello world!"); ?>
  • 27. Get and postGet and post GET METHODGET METHOD The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ?character. •Never use GET method if you have password or other sensitive information to be sent to the server. •GET can't be used to send binary data, like images or word documents, to the server. •The GET method is restricted to send upto 1024 characters only.
  • 28. <?php if( $_GET["name"] || $_GET["age"] ) { echo "Welcome ". $_GET['name']. "<br />"; echo "You are ". $_GET['age']. " years old."; exit(); } ?> <html> <body> <form action = "<?php $_PHP_SELF ?>" method = "GET"> Name: <input type = "text" name = "name" /> Age: <input type = "text" name = "age" /> <input type = "submit" /> </form> </body> </html>
  • 29. The POST MethodThe POST Method •The POST method does not have any restriction on data size to be sent. •The POST method can be used to send ASCII as well as binary data. •The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.
  • 30. Database (MYSQL) • DDL • DML • Queries • Assignments on DDL and DML • Wamp server installation