SlideShare uma empresa Scribd logo
1 de 39
Introduction to PHP Todd Barber IT Analyst III / University Webmaster Information Technology Services
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What is it? and What do I need?
Basic Syntax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],See  http://us2.php.net/manual/en/language.types.php  for all possible types and more details.
Variables ,[object Object],[object Object],[object Object],[object Object],[object Object]
More Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More Variables - Scope ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],More Variables – Scope ,[object Object],[object Object],[object Object],[object Object],3 2
More Variables - Variable ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],This outputs hello world hello world This outputs 3.14159265358979323846
Operator Precedence Associativity Operators Additional Information non-associative new new left [ array() non-associative ++ -- increment/decrement   non-associative ~ - (int) (float) (string) (array) (object) @ types   non-associative instanceof types   right ! logical   left * / % arithmetic   left + - . arithmetic  and  string left << >> bitwise   non-associative < <= > >= comparison   non-associative == != === !== comparison   left & bitwise  and  references left ^ bitwise   left | bitwise   left && logical   left || logical   left ? : ternary   right = += -= *= /= .= %= &= |= ^= <<= >>=  assignment   left and logical   left xor logical   left or logical   left , (comma) many uses
Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Comparing Different Types Operand 1 Operand 2 Result Null or String String Convert NULL to “”, numerical or lexical comparison Bool or null Anything Convert to bool, FALSE<TRUE String or number (or resource) String or number (or resource) Translate strings (and resources) to numbers, usual math Array Array ,[object Object],[object Object],[object Object],Array Anything Array is always greater
More Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Array Comparisons ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Control Structures -- if ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],if block is executed and displays Hello World – note the assignment operator in the expression if block is ignored and nothing is done – note the  comparison operator in the expression
Control Structures - else ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Control Structures - elseif ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Control Structures - while ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<?php $j = 0; while ($j <=10) { echo “j is set to “.++$j; } ?> Counts to 10 Counts to 11
Control Structures – do-while ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<?php $a=3; do { echo “The value of a is ”.$a; } while ($a==4); ?> Evaluates to FALSE and while loop statement(s) are never executed while expression isn’t evaluated until after at least one iteration  of the do-while statements.  This echoes “The value of a is 3” to the screen.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Control Structures - for <?php $i=1; while ($i<=10) { echo $i.”<br />”; $i++; } ?> functions the    same as
Control Structures - switch ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<?php $i=2; if ($i==0) echo $i; elseif ($i==1) echo $i; elseif ($i==2) echo $i; ?>
More switch <?php $i = 4; switch ($i) { case 0: case 1: case 2: case 3: echo “I is less than 4”; break; case 4: echo “I is equal to 4”; break; default: echo “I is greater than 4”; break; ?> Combining cases Omitting Breaks <?php $i = 4; switch ($i) { case 0: case 1: case 2: case 3: echo “I is less than 4”; case 4: echo “I is equal to 4”; default: echo “I is greater than 4”; ?>
Control Structures – require and include ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Control Structures –require_once and include_once ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
User-defined functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Functions and Arguments ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Function Examples
More Function Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More Function Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Variable length argument lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Returning values ,[object Object],[object Object],[object Object],[object Object],[object Object]
return() examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More return() examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More return() examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Oh, by the way… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Mais conteúdo relacionado

Mais procurados

Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 

Mais procurados (20)

07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
Php
PhpPhp
Php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
PHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet SolutionPHP - Introduction to PHP - Mazenet Solution
PHP - Introduction to PHP - Mazenet Solution
 
PHP
PHPPHP
PHP
 
php basics
php basicsphp basics
php basics
 
Dev traning 2016 basics of PHP
Dev traning 2016   basics of PHPDev traning 2016   basics of PHP
Dev traning 2016 basics of PHP
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 

Semelhante a Basic PHP

2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
mussawir20
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kian
phelios
 
PHP Underground Session 1: The Basics
PHP Underground Session 1: The BasicsPHP Underground Session 1: The Basics
PHP Underground Session 1: The Basics
Robin Hawkes
 

Semelhante a Basic PHP (20)

Php Basic
Php BasicPhp Basic
Php Basic
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 
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
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
 
Php2
Php2Php2
Php2
 
P H P Part I, By Kian
P H P  Part  I,  By  KianP H P  Part  I,  By  Kian
P H P Part I, By Kian
 
02 Php Vars Op Control Etc
02 Php Vars Op Control Etc02 Php Vars Op Control Etc
02 Php Vars Op Control Etc
 
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
 
PHP
PHP PHP
PHP
 
Expressions and Operators.pptx
Expressions and Operators.pptxExpressions and Operators.pptx
Expressions and Operators.pptx
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
PHP Underground Session 1: The Basics
PHP Underground Session 1: The BasicsPHP Underground Session 1: The Basics
PHP Underground Session 1: The Basics
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Introduction in php part 2
Introduction in php part 2Introduction in php part 2
Introduction in php part 2
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Basic PHP

  • 1. Introduction to PHP Todd Barber IT Analyst III / University Webmaster Information Technology Services
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Operator Precedence Associativity Operators Additional Information non-associative new new left [ array() non-associative ++ -- increment/decrement non-associative ~ - (int) (float) (string) (array) (object) @ types non-associative instanceof types right ! logical left * / % arithmetic left + - . arithmetic and string left << >> bitwise non-associative < <= > >= comparison non-associative == != === !== comparison left & bitwise and references left ^ bitwise left | bitwise left && logical left || logical left ? : ternary right = += -= *= /= .= %= &= |= ^= <<= >>= assignment left and logical left xor logical left or logical left , (comma) many uses
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. More switch <?php $i = 4; switch ($i) { case 0: case 1: case 2: case 3: echo “I is less than 4”; break; case 4: echo “I is equal to 4”; break; default: echo “I is greater than 4”; break; ?> Combining cases Omitting Breaks <?php $i = 4; switch ($i) { case 0: case 1: case 2: case 3: echo “I is less than 4”; case 4: echo “I is equal to 4”; default: echo “I is greater than 4”; ?>
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.

Notas do Editor

  1. Since everything is HTML embedded, must have a way of telling the server what is PHP and what is HTML. 1 and 2 are both always available, however number 1 is used most often. 3 and 4 are only available if enabled by the server administrator. Closing tag is optional. Lines of code must end in PHP.
  2. Don’t add scope until talking about functions b/c examples don’t make sense until then.
  3. Don’t add scope until talking about functions b/c examples don’t make sense until then.
  4. Form with 8 names and name1, name2, etc… and it gets submitted For loop 8 times: $temp_name = name$i echo $$temp_name // holds the actual value from the form. End of for
  5. String to number- if string starts with number or sign then it gets that value, if it starts with anything else it gets evaluated to zero.
  6. Two different variations of AND and OR because they have different precedence
  7. Point out that on single command if statements the curly braces are optional.
  8. for ($i=1;$i&lt;=10;print $i++) More on for the expressions can be blank or have multiple expressions in them. Go to php.net for more