![Page 1: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/1.jpg)
PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)
![Page 2: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/2.jpg)
INTRODUCTION PHP is a powerful tool for making dynamic and
interactive Web pages. PHP is the widely-used, free, and efficient
alternative to competitors such as Microsoft's ASP. Allow creation of e-commerce websites,login
pages, check details from a form, create forums, picture galleries, surveys.
PHP is a server-side scripting language.
![Page 3: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/3.jpg)
WHAT IS PHP? PHP stands for PHP: (Personel home page)
Hypertext Preprocessor PHP is a server-side scripting language PHP scripts are executed on the server PHP supports many databases (MySQL, Informix,
Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
PHP is an open source software PHP is free to download and use
![Page 4: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/4.jpg)
HISTORY Started as a Perl hack in 1994 by Rasmus Lerdorf (to
handle his resume), developed to PHP/FI 2.0 By 1997 up to PHP 3.0 with a new parser engine by
Zeev Suraski and Andi Gutmans Version 5.2.4 is current version, rewritten by Zend
(www.zend.com) to include a number of features, such as an object model
Current is version 5 php is one of the premier examples of what an open
source project can be
![Page 5: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/5.jpg)
PHP SYNTAX
PHP syntax is <?php ?> PHP's syntax and semantics are similar to most other
programming languages (C, Java, Perl). A PHP file normally contains HTML tags, and some PHP
scripting code. There was a semicolon after the line of PHP code.
![Page 6: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/6.jpg)
CONTINUED….
There are two basic statements to output text with PHP : echo and print.
White spaces : As with HTML, whitespace is ignored between PHP statements.
Comments in PHP : we use // to make a one-line comment
/* */ to make a comment block
![Page 7: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/7.jpg)
HOW TO SAVE YOUR PHP PAGES
instead of the .html extension.
A PHP file must have a .php extension.
![Page 8: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/8.jpg)
EXAMPLE SIMPLE HTML & PHP PAGE <html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
// This is Statement
/*
This is
a comment block*/
echo "Hello World!“;
?>
</body>
</html>
Display Output:
Hello World!
![Page 9: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/9.jpg)
•VARIABLES•ECHO FUNCTION•STRING
•USING DOUBLE QUOTES•USING SINGLE QUOTES•USING heredoc
![Page 10: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/10.jpg)
PHP VARIABLES:
A variable is a means of storing a value. The variable can then be reused throughout your code,
instead of having to type out the actual value over and over again.
In PHP you define a variable with the following form: $variable_name = Value; If you forget that dollar sign at the beginning, it will not
work. This is a common mistake for new PHP programmers!
![Page 11: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/11.jpg)
A QUICK VARIABLE EXAMPLE:
PHP Code: <?php $hello = "Hello World!"; $a_number = 4; $anotherNumber = 8; ?>
Note for programmers: PHP does not require variables to be declared before being initialized.
![Page 12: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/12.jpg)
PHP VARIABLE NAMING CONVENTIONS:
• PHP variables must start with a letter or underscore "_".
• PHP variables may only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .
• Variables with more than one word should be separated with underscores.
$my_variable • Variables with more than one word can also
be distinguished with capitalization. $myVariable
![Page 13: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/13.jpg)
PHP-ECHO FUNCTION The PHP function echo is a means of
outputting text to the web browser. PHP Code:
<?php $myString = "Hello!"; echo $myString; echo "<h5>I love using PHP!</h5>"; ?>
Display: Hello! I love using PHP!
The text we are outputting is being sent to the user in the form of a web page, so it is important that we use proper HTML syntax!
![Page 14: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/14.jpg)
ECHO STATEMENT INCREASE WITH NO. OF VARIABLES:
<?php $my_string = "Hello Bob. My name is: "; $my_number = 4; $my_letter = a; echo $my_string; echo $my_number; echo $my_letter; ?>
Display: Hello Bob. My name is: 4a
![Page 15: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/15.jpg)
WE CAN USE THE (.) TO REDUSE THE NO OF ECHO STATEMENT:
Variables and text strings are joined together with a period( . ). <?php $my_string = "Hello Bob. My name is: "; $newline = "<br />"; echo $my_string."Bobettta".$newline; echo "Hi, I'm Bob. Who are you? ".$my_string.$newline; echo "Hi, I'm Bob. Who are you? ".$my_string."Bobetta"; ?>
Display: Hello Bob. My name is: Bobetta Hi, I'm Bob. Who are you? Hello Bob. My name is:Hi, I'm Bob. Who are you? Hello Bob. My name is:
Bobetta
![Page 16: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/16.jpg)
PHP-STRING CREATION DOUBLE QUOTES
PHP Code: $my_string = "Tizag - Unlock your potential!"; echo "Tizag - Unlock your potential!"; echo $my_string;
Display: Tizag - Unlock your potential! Tizag - Unlock your potential!
![Page 17: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/17.jpg)
PHP-STRING CREATION DOUBLE QUOTESCONSTRAINTS:
• Don't use quotes inside your string • Escape your quotes that are within the string with a slash. To
escape a quote just place a slash directly before the quotation mark, i.e. \"
• Use single quotes (apostrophes) for quotes inside your string. PHP Code:
<?php // This won't work because of the quotes around specialH5! echo "<h5 class="specialH5">I love using PHP!</h5>";
// OK because we escaped the quotes! echo "<h5 class=\"specialH5\">I love using PHP!</h5>";
// OK because we used an apostrophe ' echo "<h5 class='specialH5'>I love using PHP!</h5>"; ?>
![Page 18: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/18.jpg)
PHP-STRING CREATION SINGLE QUOTES: PHP Code: $my_string = 'Tizag - Unlock your potential!';
echo 'Tizag - Unlock your potential!'; echo $my_string;
If you want to use a single-quote within the string you have to escape the single-quote with a backslash \ . Like this: \' !
PHP Code:echo 'Tizag - It\'s Neat!';
![Page 19: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/19.jpg)
PHP - STRING CREATION HEREDOC
PHP introduces a more robust string creation tool called heredoc that lets the programmer create multi-line strings without using quotations. However, creating a string using heredoc is more difficult and can lead to problems if you do not properly code your string!
PHP Code: $my_string = <<<TEST Tizag.com Webmaster Tutorials Unlock your potential! TEST; echo $my_string;
Display: Tizag.com Webmaster Tutorials Unlock your potential!
![Page 20: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/20.jpg)
PHP-STING CREATION HEREDOC
• There are a few very important things to remember when using heredoc. • Use <<< and some identifier that you choose to begin
the heredoc. In this example we chose TEST as our identifier.
• Repeat the identifier followed by a semicolon to end the heredoc string creation. In this example that was TEST;
• The closing sequence TEST; must occur on a line by itself and cannot be indented!
![Page 21: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/21.jpg)
PHP-OPERATORSTypes of operators: Assignment OperatorArithmetic OperatorComparison OperatorString OperatorCombination Arithmetic and Assignment Operator
![Page 22: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/22.jpg)
1.Assignment Operator Used to set a variable equal to a value Example: $my_var=3; $another_var=my_var;
2.Arithmetic Operator
![Page 23: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/23.jpg)
$addition = 2 + 4; $subtraction = 6 - 2; $multiplication = 5 * 3; $division = 15 / 3; $modulus = 5 % 2; echo "Perform addition: 2 + 4 = ".$addition."<br />"; echo "Perform subtraction: 6 - 2 = ".$subtraction."<br />"; echo "Perform multiplication: 5 * 3 = ".$multiplication."<br />"; echo "Perform division: 15 / 3 = ".$division."<br />"; echo "Perform modulus: 5 % 2 = " . $modulus . ". Modulus is the remainder after the division operation has been performed. In this case it was 5 / 2, which has a remainder of 1.";
![Page 24: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/24.jpg)
Output:
Perform addition: 2 + 4 = 6 Perform subtraction: 6 - 2 = 4 Perform multiplication: 5 * 3 = 15 Perform division: 15 / 3 = 5 Perform modulus: 5 % 2 = 1. Modulus is the remainder after the division operation has been performed. In this case it was 5 / 2, which has a remainder of 1.
![Page 25: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/25.jpg)
Used to check relationship between values and/or variables
Example:Assume: $x = 4 and $y = 5;Operator English Example Result
== Equal To $x == $y false
!= Not Equal To $x != $y true
< Less Than $x < $y true
> Greater Than $x > $y false
<= Less Than or Equal To $x <= $y true
>= Greater Than or Equal To $x >= $y false
3. Comparison Operators
![Page 26: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/26.jpg)
4.STRING OPERATOR
PHP Code: $a_string = "Hello"; $another_string = " Billy"; $new_string = $a_string . $another_string; echo $new_string . "!";
Output: Hello Billy!
![Page 27: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/27.jpg)
5.COMBINATION ASSIGNMENT AND ARITHMETIC OPERATOR
![Page 28: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/28.jpg)
PRE/POST INCREMENT AND PRE/POST DECREMENT
PHP Code: $x = 4; echo "The value of x with post-plusplus = " . $x++; echo "<br /> The value of x after the post-plusplus is " . $x; $x = 4; echo "<br />The value of x with with pre-plusplus = " . ++$x; echo "<br /> The value of x after the pre-plusplus is " . $x;
![Page 29: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/29.jpg)
Output:The value of x with post-plusplus = 4 The value of x after the post-plusplus is = 5 The value of x with with pre-plusplus = 5 The value of x after the pre-plusplus is = 5
![Page 30: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/30.jpg)
CONTROL STRUCTURES IN PHP: If Statement: Necessary for all programming
languages, thus important in PHP Helps in taking decisions If Statement Example:
Output
![Page 31: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/31.jpg)
IF STATEMENT CONTINUED…
False If StatementExample
Output
![Page 32: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/32.jpg)
IF-ELSE STATEMENTExample
Since if condition is true all code that is
contained between the opening curly brace "{" that follows the if statement and the closing curly brace "}" will be executed when the if statement is true.
Output
![Page 33: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/33.jpg)
IF-ELSE CONTINUED…
Else Statement is Executed if condition in If Statement is FalseExample:
Output:
![Page 34: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/34.jpg)
USING ELSE-IF WITH IF-ELSE STATEMENT Used to check multiple Conditions
Example:
Output:
Important Note: Else-if statement can’t be used unless it is
preceded by if statement
![Page 35: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/35.jpg)
SWITCH STATEMENT IN PHP:
If Statement – Not always the most efficient way to check the conditions for certain condition
Checking conditions more than 8 or 10 using if-else would end in nasty long block of If/ElseIf/ElseIf/ElseIf….. Statements.
Using Switch, all the conditions are checked at once
Use of Switch- More Efficient way of Programming
![Page 36: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/36.jpg)
SWITCH STATEMENT CONTINUED…
Example:
Output:
![Page 37: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/37.jpg)
SWITCH STATEMENT CONTINUED…
Break- Used at the end of each case
Break prevents the other cases from being
executed
Absence of Break leads to Fallthrough.
When variables doesn’t match our condition-
As If statement has Else Clause
Similarly, Switch Statement has default
case which is executed
![Page 38: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/38.jpg)
LOOPING STRUCTURES
Repetitive tasks are always burden to us
Examples: Deleting spam emails, sealing 50
envelops
• Repetitive tasks can be avoided using loops
• The idea of loop is to do something over
and over again until the task has been
completed
• Repetitive tasks are conquered in loops.
![Page 39: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/39.jpg)
WHILE LOOP The function of the while loop is to do a
task over and over as long as the specified conditional statement is true.
The logical check is the same as the one that appears in a PHP if statement to determine if it is true or false.
General Syntax:
If the conditional statement is false, then the code within is not executed and there is no more looping
![Page 40: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/40.jpg)
WHILE LOOP CONTINUED… Real Life Example
![Page 41: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/41.jpg)
FOR LOOP The for loop is simply a while loop with
a bit more code added to it. The common tasks that are covered by a for loop are:
1. Set a counter variable to some initial value.
2. Check to see if the conditional statement is true.
3. Execute the code within the loop. 4. Increment a counter at the end of
each iteration through the loop. General Syntax:
![Page 42: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/42.jpg)
FOR LOOP CONTINUED…
Real Life Example:
![Page 43: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/43.jpg)
DO-WHILE LOOP
A "do while" loop is a slightly modified version of the while loop.
In case of while loops the condition is checked first , if it is false the code within the while loop is not execute.
On the other hand, do-while loop always executes its block of code at least once.
This is because the conditional statement is not checked until after the contained code has been executed.
![Page 44: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/44.jpg)
WHILE VS DO-WHILE
Real Life Example: While
Output
Do-While
Output
![Page 45: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/45.jpg)
PHP FUNCTIONS….
The actual syntax for creating a function is pretty self-explanatory, but you can be the judge of that. First, you must tell PHP that you want to create a function. You do this by typing the keyword function followed by your function name and some other stuff Note: Your function name can start with a letter or underscore "_", but not a number!
![Page 46: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/46.jpg)
![Page 47: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/47.jpg)
![Page 48: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/48.jpg)
![Page 49: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/49.jpg)
Disadvantages
PHP is loosely typed language.
PHP tends to execute more slowly than assembly, C, and other compiled languages. Web programming is open to security flaws due to unimplemented or unknown vulnerabilities.
![Page 50: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/50.jpg)
ApplicationsCommand-line scripting
Client-side GUI applications.
Deployed on most web servers, many operating systems and platforms,
Used with many RDBMS
PHP primarily acts as a filter.
![Page 51: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/51.jpg)
PHP EDITORS…
BLUEFISH
PHPeclipse
![Page 52: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/52.jpg)
DEMO…….<?php
$Fname = $_POST["Fname"];$Lname = $_POST["Lname"];$gender = $_POST["gender"];$food = $_POST["food"];$quote = $_POST["quote"];$education = $_POST["education"];$TofD = $_POST["TofD"];if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form?><html><head><title>Personal INFO</title></head><body><form method="post" action="<?php echo $PHP_SELF;?>">
![Page 53: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/53.jpg)
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br />Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />Gender:<br />Male:<input type="radio" value="Male" name="gender"><br />Female:<input type="radio" value="Female" name="gender"><br />Please choose type of residence:<br />Steak:<input type="checkbox" value="Steak" name="food[]"><br />Pizza:<input type="checkbox" value="Pizza" name="food[]"><br />Chicken:<input type="checkbox" value="Chicken" name="food[]"><br /><textarea rows="5" cols="20" name="quote" wrap="physical">Enter your favorite quote!</textarea><br />Select a Level of Education:<br /><select name="education"><option value="Jr.High">Jr.High</option><option value="HighSchool">HighSchool</option><option value="College">College</option></select><br />Select your favorite time of day:<br /><select name="TofD" size="3"><option value="Morning">Morning</option><option value="Day">Day</option><option value="Night">Night</option></select><br /><input type="submit" value="submit" name="submit"></form>
![Page 54: PHP Presented By 1.Shivshankar Sawale(J-55) 2.Vaishali Nagalwar(J-44) 3.Swati Lohiya(J-41) 4.Prayaga Ahirrao(J-5) 5.Jaya Nenwani(J-45) 6.Prerna Raskar(J-52)](https://reader036.vdocument.in/reader036/viewer/2022062422/56649f395503460f94c563cd/html5/thumbnails/54.jpg)
<?} else {echo "Hello, ".$Fname." ".$Lname.".<br />";echo "You are ".$gender.", and you like ";foreach ($food as $f) {echo $f."<br />";}echo "<i>".$quote."</i><br />";echo "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";}?>