際際滷

際際滷Share a Scribd company logo
PHP PPT FILE
What is php
PHP = PHP: Hypertext Preprocessor | Server-
side scripting language that may be embedded into
HTML | Ultimate goal is to get PHP files to generate
client side code | must end up with HTML, CSS,
JavaScript, other client .
:
SIDE BY SIDE
PHP FILE HTML FILE OUTPUT
<head> <Head>
<Title introducing php < /Title> <title introducing php< /title>
<Body> <body
<?php HELLO WORLD
ECHO HELLO WORLD </body>
?> Print(output)
</Body> HELLO WORLD
Introducing php
PHP TAGS
Single line comment (//)
Multiple line comment (/* and /*)
The echo command
VIEWING PHP FILE
PHP files executed on the web server
_| Therefore we cannot save them anywhere and view them, as with HTML files
_| Must save .php files in subdirectory of web server
var/www/ on many Linux configurations
_| www directory of your user directory on Athena
_| Make call to web server via domain name (google.com), IP address (127.0.0.1), or
localhost
if on your own computer
PHP
Syntax: Variables,
Operators, and Strings
VARIABLE'S
Store values for future reference, use variable name to refer to the
value stored in it PHP is a loosely-typed language Do not need to
declare the type of a variable
Type can change throughout the program $x = 42:
//
store the value 42 in $x echo $x; // prints 42 echo $x+1; // prints
43, value of $x is still 42 $x = hello! // type of $x can change
OPRATER'S
Arithmetic operators
+,-,*/,% (modulus - remainder after division)
Logical AND (&&), OR (||), NOT (!)
Assignment operators Shorthand for assignment operators: $x +=
$y equivalent to $x = $x + $y Also works with subtraction,
multiplication, division, modulus, and string concatenation
 VERSUS
Two equality operator == tests for equality in
value but not necessarily
type === tests for identity in value AND type ==
ignores the distinction between: Integers, floating
point numbers, and strings containing the same
numerical value Nonzero numbers and boolean
TRUE
Zero and boolean FALSE
STRING'S
A sequence of characters Single and double quotes: suppose $str = 42;
| echo With single quotes, str is $str; 7 output:
With single quotes, str is $str ~ echo With double quotes, str is $str; ~
output: With double quotes, str is 42
STRING'S
Col icatenation of rings - the . operator | String aie ictions 7
Length: strlen() | Position of substring: strpos()
_ More on string functions:
http://www.w3schools.com/php/php_ref_string.asp $a
=hello; pb = = wor rid; echo $a.. $b.!: // prints hello
world!
CONDITIONAL STATEMENTS
if (condition / boolean expression) { statements
else if (another condition) { statements
// there may be more than one else if block else { statements
$x = 5; if(Sx*=5){ echo The variable x has value 5!:
THE WHILE LOOP
while (condition) { statements } x <
1000) { echo $x. n: //is newline character
$x = $x * $x;
THE DO WHILE LOOP
The code within the loop is executed at least once,
regardless of ae = condition is true O statements }
while (condition); equivalent to: statements while
(condition) { statements
CONDITIONAL STATEMENTS
if (condition / boolean expression) { statements
else if (another condition) { statements
// there may be more than one else if block
else { statements
} = 5; a ){
echo The variable x has value 5!:
THE WHILE LOOP
while (condition) { statements j x < 1000) { echo
$x.n; //newline character
$x = $x * $x;
THE DO WHILE LOOP
The code within the loop is executed at least once,
regardless of whether the condition is true do {
statements } while (condition); equivalent to:
statements while (condition) { statements
THE FOR LOOP
for (init; condition; increment) {
ie Cae equivalent to: init while (condition) { statements
increment
Prints the first 10 positive integers and their squares:
f i= 1; $i <= 10; $i a ae * 蔵i) ir)
} Defining your fucation
function function_name ($arg1, $arg2) { function code return $var //optional } True funcation
Example: a simple multiply function
function Re { x * $y;
echo echo : multiply(5, 1.2); 2 prints 6 $a=5; Sip.
error a, $b); 7 prints O (?!)
RETURN VALUE'S
| A function can return a value after it is done
_| Use this value in future computation, use like a variable, assign value to a variable
A modified multiply function
function multiply($x, $y) {
return $x * $y;
j
multiply(2,3); 3 prints nothing! returns value, but we dont store anywhere echo multiply(2,3); 息 prints 6
$a = multiply(2,3); 0 assigns the value 6 to the variable $a
$b = multiply(multiply(2,3), multiply(3,4)); 息 assigns the value 72 to the variable $b
RETURN VALUE'S
puecten can return at most once, and it can only return one value
| If it does not return anything, assignments will result in NULL _| A function ends after it returns, even if there
is code following the return statement
function do_stuff($x) {
if ($x % 2 == 0) { //if even
return $x/2 // exits function at this point
}
// this is ONLY executed if x is odd $x += 5;
if ($x < 10) {
$x += 3;
MAKING FUNCATION CALL
Code inside of a function is not executed unless the function is called.
Code outside of functions is executed whenever the program is
executed.  <2PHP
.. // some code function1(): // makes function call to functioni(), which
/finturn calls function3() function function1() { .. // some code
function3(): // makes function call to function3()
function functiona() { // this function is never called! . // some code
function function3() { i # some code
Arry as alist of elements
Use arrays to keep track of a list of elements using the same variable
name, identifying each element by its index, starting with O
$colors = array(red, blue, green, black, yellow; To add an element to
the array:
$colors[] = purple;
息 Toremove an element from the array: unset($colors[2]); colors); Recap
:arrays
print_r($array_name) function lets you easily
RECAP:ARRAY
View the contents of an array
PHP arrays as alist PHP arrays as a map $favorite_colors =
array(Joe => blue, Elena => green, Mark => brown,
Adrian => black, Charles => red): colors[Adrian]):
$colors = array(red, blue, green, black, yellow;
colors[1]): colors); All
All arrays are associative
Each element in an array will have a unique key,
whether you specify it or not.
EXAMPLE $colors = array(red, blue, green, black,
yellow);
print_ pacolers gives: Array( 3 =>red => blue tae reen =>
black [4] => yellow
For each loop
The for-each loops allow for easy iteration over all elements of an array.
foreach ($array_name as $value) { code here
foreach ($array_name as $key => $value) { code here
foreach ($colors as $color) { echo $color; // simply prints each color
foreach ($colors as $number => color) {
echo $number => $color; // prints color with index // to change an element:
// number] = $new_color
When to use $ get vs.$_post
1.GET requests are sent via the URL, and can thus be
cached, bookmarked, shared, etc
2.GET requests are limited by the length of the URL
3. POST requests are not exposed in the URL and should be used for
sensitive data
4. There is no limit to the amount of information
passed via _POST
FORMS:SERVER-SIDE
A simple PHP file that displays what was entered into the form
Can do many other things server-side depending on the situation
Note the use of $ _POST
COOKIES AND SESSIONS
HTTP is stateless  it does not keep track of the client between requests
But sometimes we need to keep track of this information
Shopping cart | Remember me on login sites | 2 solutions to this issue ~ Cookies -
small file stored client-side _ Sessions - relevant data stored on the server
EXAMPLE OF COOKIES USAGE
Main disadvantages of cookies
_| Limited in size by browser
_] Stored client-side ~ can be tampered with
_| Sessions store user data on the server
_| Limited only by server space
-| Cannot be modified by users
_| A potential downside to sessions is that they expire
when the browser Is closed
_ Sessions are identified by a session Id: often a small cookie! But the rest of the data is still stored on the server. Using
session
Using session
Call session_start() at top of every page to start session U Sets a cookie on the
client: must follow same rules as cookies (before any HTML, CSS, JS, echo or print
statements)
0 Access data using the $_ SESSION superglobal, just like $ COOKIE, $_GET, or
$_POST
Using session
<?php {
Session start () $session [count]==1;
If(isset($session ([count]))); echo you visited once ;
{ }
$session [count]=1; ?>
Echo visited here;
{
Else
Indore Institute of Computer Education (IICE)
http://www.iiceducation.in/
IICE (Indore Institute of Computer Education) is the leading training institute in Indore, India. We have developed ourselves into
a well-known brand in the education sector of the country. We offer a wide range of courses that are designed to provide a
well-rounded education to the students so that they can gain a competitive edge in the current job markets.

More Related Content

What's hot (20)

Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
Andrew Shitov
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
Sanketkumar Biswas
Php functions
Php functionsPhp functions
Php functions
JIGAR MAKHIJA
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
Class 8 - Database Programming
Class 8 - Database ProgrammingClass 8 - Database Programming
Class 8 - Database Programming
Ahmed Swilam
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
brian d foy
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
Lin Yo-An
What's New in Perl? v5.10 - v5.16
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
Ricardo Signes
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
Lin Yo-An
Refactor like a boss
Refactor like a bossRefactor like a boss
Refactor like a boss
gsterndale
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
brian d foy
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
Business Rules with Brick
Business Rules with BrickBusiness Rules with Brick
Business Rules with Brick
brian d foy
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
Fabien Potencier
Functions in PHP
Functions in PHPFunctions in PHP
Functions in PHP
Vineet Kumar Saini
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
Mohammad Imam Hossain
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
lichtkind
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
Andrew Shitov
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
Mark Niebergall
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
Andrew Shitov
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
Class 8 - Database Programming
Class 8 - Database ProgrammingClass 8 - Database Programming
Class 8 - Database Programming
Ahmed Swilam
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
brian d foy
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
Lin Yo-An
What's New in Perl? v5.10 - v5.16
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
Ricardo Signes
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
Lin Yo-An
Refactor like a boss
Refactor like a bossRefactor like a boss
Refactor like a boss
gsterndale
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
brian d foy
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
Business Rules with Brick
Business Rules with BrickBusiness Rules with Brick
Business Rules with Brick
brian d foy
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
lichtkind

Similar to PHP PPT FILE (20)

php AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdfphp AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdf
SVN Polytechnic Kalan Sultanpur UP
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
Vineet Kumar Saini
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptxPHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
kamalsmail1
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
rani marri
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
Norhisyam Dasuki
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
Chris Chubb
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
Php
PhpPhp
Php
Rajkiran Mummadi
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
Denis Ristic
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
outcast96
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
Programmer Blog
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
Britta Alex
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
prabhatjon
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
lachie
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
Vineet Kumar Saini
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptxPHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
kamalsmail1
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
rani marri
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
Chris Chubb
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
Denis Ristic
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
outcast96
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
Programmer Blog
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
Britta Alex
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
prabhatjon
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
lachie

Recently uploaded (20)

Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdfBlind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Ajaz Hussain
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷sHow to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
Celine George
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptxTLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
RizaBedayo
TPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategyTPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategy
Henry Tapper
Database population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slidesDatabase population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slides
Celine George
Modeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptxModeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptx
maribethlacno2
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, TuluThe Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
DrIArulAram
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
DrNidhiAgarwal
Information Technology for class X CBSE skill Subject
Information Technology for class X CBSE skill SubjectInformation Technology for class X CBSE skill Subject
Information Technology for class X CBSE skill Subject
VEENAKSHI PATHAK
Research & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptxResearch & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptx
Dr. Sarita Anand
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
pinkdvil200
APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...
APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...
APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...
Association for Project Management
Computer Application in Business (commerce)
Computer Application in Business (commerce)Computer Application in Business (commerce)
Computer Application in Business (commerce)
Sudar Sudar
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
A PPT Presentation on The Princess and the God: A tale of ancient India  by A...A PPT Presentation on The Princess and the God: A tale of ancient India  by A...
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
Beena E S
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
Association for Project Management
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
POWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptx
POWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptxPOWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptx
POWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptx
MarilenQuintoSimbula
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptxFESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
DanmarieMuli1
Storytelling instructions...............
Storytelling instructions...............Storytelling instructions...............
Storytelling instructions...............
Alexander Benito
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdfBlind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Ajaz Hussain
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷sHow to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
How to Setup WhatsApp in Odoo 17 - Odoo 際際滷s
Celine George
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptxTLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
RizaBedayo
TPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategyTPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategy
Henry Tapper
Database population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slidesDatabase population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slides
Celine George
Modeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptxModeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptx
maribethlacno2
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, TuluThe Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
The Dravidian Languages: Tamil, Telugu, Kannada, Malayalam, Brahui, Kuvi, Tulu
DrIArulAram
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
DrNidhiAgarwal
Information Technology for class X CBSE skill Subject
Information Technology for class X CBSE skill SubjectInformation Technology for class X CBSE skill Subject
Information Technology for class X CBSE skill Subject
VEENAKSHI PATHAK
Research & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptxResearch & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptx
Dr. Sarita Anand
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1 2024  Lesson Plan M1...
Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1 2024 Lesson Plan M1...
pinkdvil200
APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...
APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...
APM People Interest Network Conference - Oliver Randall & David Bovis - Own Y...
Association for Project Management
Computer Application in Business (commerce)
Computer Application in Business (commerce)Computer Application in Business (commerce)
Computer Application in Business (commerce)
Sudar Sudar
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
A PPT Presentation on The Princess and the God: A tale of ancient India  by A...A PPT Presentation on The Princess and the God: A tale of ancient India  by A...
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
Beena E S
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
Association for Project Management
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
POWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptx
POWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptxPOWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptx
POWERPOINT-PRESENTATION_DM-NO.017-S.2025.pptx
MarilenQuintoSimbula
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptxFESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
DanmarieMuli1
Storytelling instructions...............
Storytelling instructions...............Storytelling instructions...............
Storytelling instructions...............
Alexander Benito

PHP PPT FILE

  • 2. What is php PHP = PHP: Hypertext Preprocessor | Server- side scripting language that may be embedded into HTML | Ultimate goal is to get PHP files to generate client side code | must end up with HTML, CSS, JavaScript, other client . :
  • 3. SIDE BY SIDE PHP FILE HTML FILE OUTPUT <head> <Head> <Title introducing php < /Title> <title introducing php< /title> <Body> <body <?php HELLO WORLD ECHO HELLO WORLD </body> ?> Print(output) </Body> HELLO WORLD
  • 4. Introducing php PHP TAGS Single line comment (//) Multiple line comment (/* and /*) The echo command
  • 5. VIEWING PHP FILE PHP files executed on the web server _| Therefore we cannot save them anywhere and view them, as with HTML files _| Must save .php files in subdirectory of web server var/www/ on many Linux configurations _| www directory of your user directory on Athena _| Make call to web server via domain name (google.com), IP address (127.0.0.1), or localhost if on your own computer
  • 7. VARIABLE'S Store values for future reference, use variable name to refer to the value stored in it PHP is a loosely-typed language Do not need to declare the type of a variable Type can change throughout the program $x = 42: // store the value 42 in $x echo $x; // prints 42 echo $x+1; // prints 43, value of $x is still 42 $x = hello! // type of $x can change
  • 8. OPRATER'S Arithmetic operators +,-,*/,% (modulus - remainder after division) Logical AND (&&), OR (||), NOT (!) Assignment operators Shorthand for assignment operators: $x += $y equivalent to $x = $x + $y Also works with subtraction, multiplication, division, modulus, and string concatenation
  • 9. VERSUS Two equality operator == tests for equality in value but not necessarily type === tests for identity in value AND type == ignores the distinction between: Integers, floating point numbers, and strings containing the same numerical value Nonzero numbers and boolean TRUE Zero and boolean FALSE
  • 10. STRING'S A sequence of characters Single and double quotes: suppose $str = 42; | echo With single quotes, str is $str; 7 output: With single quotes, str is $str ~ echo With double quotes, str is $str; ~ output: With double quotes, str is 42
  • 11. STRING'S Col icatenation of rings - the . operator | String aie ictions 7 Length: strlen() | Position of substring: strpos() _ More on string functions: http://www.w3schools.com/php/php_ref_string.asp $a =hello; pb = = wor rid; echo $a.. $b.!: // prints hello world!
  • 12. CONDITIONAL STATEMENTS if (condition / boolean expression) { statements else if (another condition) { statements // there may be more than one else if block else { statements $x = 5; if(Sx*=5){ echo The variable x has value 5!:
  • 13. THE WHILE LOOP while (condition) { statements } x < 1000) { echo $x. n: //is newline character $x = $x * $x;
  • 14. THE DO WHILE LOOP The code within the loop is executed at least once, regardless of ae = condition is true O statements } while (condition); equivalent to: statements while (condition) { statements
  • 15. CONDITIONAL STATEMENTS if (condition / boolean expression) { statements else if (another condition) { statements // there may be more than one else if block else { statements } = 5; a ){ echo The variable x has value 5!:
  • 16. THE WHILE LOOP while (condition) { statements j x < 1000) { echo $x.n; //newline character $x = $x * $x;
  • 17. THE DO WHILE LOOP The code within the loop is executed at least once, regardless of whether the condition is true do { statements } while (condition); equivalent to: statements while (condition) { statements
  • 18. THE FOR LOOP for (init; condition; increment) { ie Cae equivalent to: init while (condition) { statements increment Prints the first 10 positive integers and their squares: f i= 1; $i <= 10; $i a ae * 蔵i) ir) } Defining your fucation function function_name ($arg1, $arg2) { function code return $var //optional } True funcation Example: a simple multiply function function Re { x * $y; echo echo : multiply(5, 1.2); 2 prints 6 $a=5; Sip. error a, $b); 7 prints O (?!)
  • 19. RETURN VALUE'S | A function can return a value after it is done _| Use this value in future computation, use like a variable, assign value to a variable A modified multiply function function multiply($x, $y) { return $x * $y; j multiply(2,3); 3 prints nothing! returns value, but we dont store anywhere echo multiply(2,3); 息 prints 6 $a = multiply(2,3); 0 assigns the value 6 to the variable $a $b = multiply(multiply(2,3), multiply(3,4)); 息 assigns the value 72 to the variable $b
  • 20. RETURN VALUE'S puecten can return at most once, and it can only return one value | If it does not return anything, assignments will result in NULL _| A function ends after it returns, even if there is code following the return statement function do_stuff($x) { if ($x % 2 == 0) { //if even return $x/2 // exits function at this point } // this is ONLY executed if x is odd $x += 5; if ($x < 10) { $x += 3;
  • 21. MAKING FUNCATION CALL Code inside of a function is not executed unless the function is called. Code outside of functions is executed whenever the program is executed. <2PHP .. // some code function1(): // makes function call to functioni(), which /finturn calls function3() function function1() { .. // some code function3(): // makes function call to function3() function functiona() { // this function is never called! . // some code function function3() { i # some code
  • 22. Arry as alist of elements Use arrays to keep track of a list of elements using the same variable name, identifying each element by its index, starting with O $colors = array(red, blue, green, black, yellow; To add an element to the array: $colors[] = purple; 息 Toremove an element from the array: unset($colors[2]); colors); Recap :arrays print_r($array_name) function lets you easily
  • 23. RECAP:ARRAY View the contents of an array PHP arrays as alist PHP arrays as a map $favorite_colors = array(Joe => blue, Elena => green, Mark => brown, Adrian => black, Charles => red): colors[Adrian]): $colors = array(red, blue, green, black, yellow; colors[1]): colors); All
  • 24. All arrays are associative Each element in an array will have a unique key, whether you specify it or not. EXAMPLE $colors = array(red, blue, green, black, yellow); print_ pacolers gives: Array( 3 =>red => blue tae reen => black [4] => yellow
  • 25. For each loop The for-each loops allow for easy iteration over all elements of an array. foreach ($array_name as $value) { code here foreach ($array_name as $key => $value) { code here foreach ($colors as $color) { echo $color; // simply prints each color foreach ($colors as $number => color) { echo $number => $color; // prints color with index // to change an element: // number] = $new_color
  • 26. When to use $ get vs.$_post 1.GET requests are sent via the URL, and can thus be cached, bookmarked, shared, etc 2.GET requests are limited by the length of the URL 3. POST requests are not exposed in the URL and should be used for sensitive data 4. There is no limit to the amount of information passed via _POST
  • 27. FORMS:SERVER-SIDE A simple PHP file that displays what was entered into the form Can do many other things server-side depending on the situation Note the use of $ _POST
  • 28. COOKIES AND SESSIONS HTTP is stateless it does not keep track of the client between requests But sometimes we need to keep track of this information Shopping cart | Remember me on login sites | 2 solutions to this issue ~ Cookies - small file stored client-side _ Sessions - relevant data stored on the server
  • 29. EXAMPLE OF COOKIES USAGE Main disadvantages of cookies _| Limited in size by browser _] Stored client-side ~ can be tampered with _| Sessions store user data on the server _| Limited only by server space -| Cannot be modified by users _| A potential downside to sessions is that they expire when the browser Is closed _ Sessions are identified by a session Id: often a small cookie! But the rest of the data is still stored on the server. Using session
  • 30. Using session Call session_start() at top of every page to start session U Sets a cookie on the client: must follow same rules as cookies (before any HTML, CSS, JS, echo or print statements) 0 Access data using the $_ SESSION superglobal, just like $ COOKIE, $_GET, or $_POST
  • 31. Using session <?php { Session start () $session [count]==1; If(isset($session ([count]))); echo you visited once ; { } $session [count]=1; ?> Echo visited here; { Else
  • 32. Indore Institute of Computer Education (IICE) http://www.iiceducation.in/ IICE (Indore Institute of Computer Education) is the leading training institute in Indore, India. We have developed ourselves into a well-known brand in the education sector of the country. We offer a wide range of courses that are designed to provide a well-rounded education to the students so that they can gain a competitive edge in the current job markets.