SlideShare a Scribd company logo
1 of 10
Download to read offline
Intro to Server-Side Programming 
Week Two
PHP As A Language 
• PHP can be treated as a distinct language with it’s own rules 
• It has it’s own vocabulary - words that are familiar to the 
language 
• PHP has distinct grammatical rules 
• Syntax - rules to determine the composition of sentences 
• Semantics - the meaning and significance of words 
• Structure - the relationship between words
Grammar and Vocaublary 
• Reserved Words and Keywords: if, else, ifelse; for, foreach, while, do; 
and, or, xor; public, private, protected 
• Expressions: semicolon (;), curly braces ({...}) 
• Arithmetic: addition (+), subtraction (-), multiplication(*) 
• Comparisons: equality (==), inequalities (!=), ranges (<=) 
• Special cases: dollar($), braces ([...]), operators (&, |, <<) 
• User & Built-in Constants: PHP_VERSION, E_ERROR, E_WARNING, 
E_NOTICE, MY_CONSTANT 
• User & Built-in Functions: shuffle(), printf(), strlen()
The PHP Manual - http://php.net/manual/en/ 
• In your “assignments” workspace, create a file called “assignment-2.1.md” to work on your 
answers to the following questions: 
• Find at least three different methods to get a random value from an array 
with a built-in function (Look in Array Functions) 
• What does the built-in md5() function do? What is the default return 
value? What built-in functions work similarly? 
• What is another name for “anonymous functions” in PHP and where are 
they in the manual? When were they added and what was the last 
feature added? 
• What is the default value of the “memory_limit” setting in PHP? What 
value would I set to it in order to allocate ALL memory to PHP? How 
could I set that value and where would I find that in the manual?
Data Types - Literals 
• Literals are also known as Primitive Values 
• Representative of fixed values, such as numbers or text 
• Four scalar types: boolean, integer, float (double) & string 
• Two compound types: array & object 
• Three special types: resource, NULL & callable 
• What makes 1 different from 1.0?
Working With Variables 
• Variables are storage locations with identifiers that contain values 
• Variables are places to store your literals. Think of a bucket. 
$a_variable // This is a bucket to hold literals! 
$a_variable = “some value” // Now the bucket has stuff in it 
$a_variable = “something else” // The bucket remains, but a new 
string is put in it 
• Variables in PHP are always preceded with a dollar sign ($) 
• Variables are not very useful empty, so they are usually followed with an 
assignment operator
Assignment Operators 
• An operator accepts one or more literals or variables, 
performs an operation on them and returns the results, 
like a calculator. 
$total = 1 // total is defined as 1 
$total = $total + 1 // total is now 2 
$total += 2 // total is now 4 (old total plus 2) 
• Orders of operation and precedence still apply here!
Basic “Phrases” 
• Variables, basic expressions and comments: 
$david = ‘awesome’; // not entirely true 
• Basic assignment and arithmetic operators: 
$counter = 1; $counter = 2; 
$counter = 1 + 1; 
$counter += 2; 
• Getting feedback from PHP: 
echo $counter; 
var_dump($counter); var_export($counter);
Assignment Two
Pulling Files From Git (cont) 
• Open the project that you forked earlier or fork one now 
• Grab around 50 lines of PHP from that project that show 
examples of literals, variables, function calls and other 
colored (important) things 
• If there is something that you don’t recognize, note it for 
later 
• The goal is to practice “reading” PHP grammar for now

More Related Content

What's hot

Chapter1pp
Chapter1ppChapter1pp
Chapter1ppJ. C.
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaAtul Sehdev
 
Object Oriented Programming in Java _lecture 1
Object Oriented Programming in Java _lecture 1Object Oriented Programming in Java _lecture 1
Object Oriented Programming in Java _lecture 1Mahmoud Alfarra
 
Power shell basics day 4
Power shell basics day 4Power shell basics day 4
Power shell basics day 4Ashish Raj
 
F# Type Providers in Depth
F# Type Providers in DepthF# Type Providers in Depth
F# Type Providers in DepthTomas Petricek
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsNicolas Demengel
 
Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Anwar Ul Haq
 
A Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaA Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaTomer Gabel
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUSkills Matter
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersHuffPost Code
 

What's hot (19)

Chapter1pp
Chapter1ppChapter1pp
Chapter1pp
 
Andy On Closures
Andy On ClosuresAndy On Closures
Andy On Closures
 
Unit 4 plsql
Unit 4  plsqlUnit 4  plsql
Unit 4 plsql
 
Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
 
Javanotes
JavanotesJavanotes
Javanotes
 
Object Oriented Programming in Java _lecture 1
Object Oriented Programming in Java _lecture 1Object Oriented Programming in Java _lecture 1
Object Oriented Programming in Java _lecture 1
 
Power shell basics day 4
Power shell basics day 4Power shell basics day 4
Power shell basics day 4
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Mdst 3559-02-17-php2
Mdst 3559-02-17-php2Mdst 3559-02-17-php2
Mdst 3559-02-17-php2
 
[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP[OOP - Lec 01] Introduction to OOP
[OOP - Lec 01] Introduction to OOP
 
F# Type Providers in Depth
F# Type Providers in DepthF# Type Providers in Depth
F# Type Providers in Depth
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 
Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Object Oriented Programming lecture 1
Object Oriented Programming lecture 1
 
A Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaA Field Guide to DSL Design in Scala
A Field Guide to DSL Design in Scala
 
Xpath1
Xpath1Xpath1
Xpath1
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPU
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
 

Viewers also liked

Introduction to mobile usability
Introduction to mobile usabilityIntroduction to mobile usability
Introduction to mobile usabilityopendataottawa
 
Hooks, Actions, and Filters Oh My!
Hooks, Actions, and Filters Oh My!Hooks, Actions, and Filters Oh My!
Hooks, Actions, and Filters Oh My!David Wolfpaw
 
WordPress tools and plugins
WordPress tools and pluginsWordPress tools and plugins
WordPress tools and pluginsDavid Wolfpaw
 
DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014David Wolfpaw
 
DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014David Wolfpaw
 
DIG1108C Lesson 5 Fall 2014
DIG1108C Lesson 5 Fall 2014DIG1108C Lesson 5 Fall 2014
DIG1108C Lesson 5 Fall 2014David Wolfpaw
 
Dig1108C Lesson 1 Fall 2014
Dig1108C Lesson 1 Fall 2014Dig1108C Lesson 1 Fall 2014
Dig1108C Lesson 1 Fall 2014David Wolfpaw
 
WordPress as a Minimum Viable Product - WordCamp Tampa 2014
WordPress as a Minimum Viable Product - WordCamp Tampa 2014WordPress as a Minimum Viable Product - WordCamp Tampa 2014
WordPress as a Minimum Viable Product - WordCamp Tampa 2014David Wolfpaw
 
Becoming a Respected WordPress Developer
Becoming a Respected WordPress DeveloperBecoming a Respected WordPress Developer
Becoming a Respected WordPress DeveloperDavid Wolfpaw
 
DIG1108C Lesson 4 Fall 2014
DIG1108C Lesson 4 Fall 2014DIG1108C Lesson 4 Fall 2014
DIG1108C Lesson 4 Fall 2014David Wolfpaw
 
Spring Cleaning on Your Site
Spring Cleaning on Your SiteSpring Cleaning on Your Site
Spring Cleaning on Your SiteDavid Wolfpaw
 

Viewers also liked (12)

Introduction to mobile usability
Introduction to mobile usabilityIntroduction to mobile usability
Introduction to mobile usability
 
Hooks, Actions, and Filters Oh My!
Hooks, Actions, and Filters Oh My!Hooks, Actions, and Filters Oh My!
Hooks, Actions, and Filters Oh My!
 
Oc bus tracker_120602
Oc bus tracker_120602Oc bus tracker_120602
Oc bus tracker_120602
 
WordPress tools and plugins
WordPress tools and pluginsWordPress tools and plugins
WordPress tools and plugins
 
DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014
 
DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014DIG1108C Lesson 7 Fall 2014
DIG1108C Lesson 7 Fall 2014
 
DIG1108C Lesson 5 Fall 2014
DIG1108C Lesson 5 Fall 2014DIG1108C Lesson 5 Fall 2014
DIG1108C Lesson 5 Fall 2014
 
Dig1108C Lesson 1 Fall 2014
Dig1108C Lesson 1 Fall 2014Dig1108C Lesson 1 Fall 2014
Dig1108C Lesson 1 Fall 2014
 
WordPress as a Minimum Viable Product - WordCamp Tampa 2014
WordPress as a Minimum Viable Product - WordCamp Tampa 2014WordPress as a Minimum Viable Product - WordCamp Tampa 2014
WordPress as a Minimum Viable Product - WordCamp Tampa 2014
 
Becoming a Respected WordPress Developer
Becoming a Respected WordPress DeveloperBecoming a Respected WordPress Developer
Becoming a Respected WordPress Developer
 
DIG1108C Lesson 4 Fall 2014
DIG1108C Lesson 4 Fall 2014DIG1108C Lesson 4 Fall 2014
DIG1108C Lesson 4 Fall 2014
 
Spring Cleaning on Your Site
Spring Cleaning on Your SiteSpring Cleaning on Your Site
Spring Cleaning on Your Site
 

Similar to DIG1108C Lesson 2 Fall 2014 (20)

MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
05php
05php05php
05php
 
05php
05php05php
05php
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
php
phpphp
php
 
rtwerewr
rtwerewrrtwerewr
rtwerewr
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
05php
05php05php
05php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
php basic part one
php basic part onephp basic part one
php basic part one
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
Intro about PHP,PHP Training in jaipur
Intro about PHP,PHP Training in jaipurIntro about PHP,PHP Training in jaipur
Intro about PHP,PHP Training in jaipur
 

More from David Wolfpaw

Running Your Service Business on WordPress
Running Your Service Business on WordPressRunning Your Service Business on WordPress
Running Your Service Business on WordPressDavid Wolfpaw
 
Stop the Green Light Panic - Lisa Melegari
Stop the Green Light Panic - Lisa MelegariStop the Green Light Panic - Lisa Melegari
Stop the Green Light Panic - Lisa MelegariDavid Wolfpaw
 
php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!David Wolfpaw
 
DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014David Wolfpaw
 
Beginner Workshop WCMIA
Beginner Workshop WCMIABeginner Workshop WCMIA
Beginner Workshop WCMIADavid Wolfpaw
 
Basic word press development
Basic word press developmentBasic word press development
Basic word press developmentDavid Wolfpaw
 
Geekaboo presentation 2013 - Brett Napoli
Geekaboo presentation 2013 - Brett NapoliGeekaboo presentation 2013 - Brett Napoli
Geekaboo presentation 2013 - Brett NapoliDavid Wolfpaw
 
Organization methods in word press
Organization methods in word pressOrganization methods in word press
Organization methods in word pressDavid Wolfpaw
 

More from David Wolfpaw (8)

Running Your Service Business on WordPress
Running Your Service Business on WordPressRunning Your Service Business on WordPress
Running Your Service Business on WordPress
 
Stop the Green Light Panic - Lisa Melegari
Stop the Green Light Panic - Lisa MelegariStop the Green Light Panic - Lisa Melegari
Stop the Green Light Panic - Lisa Melegari
 
php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!php[world] Hooks, Actions and Filters Oh My!
php[world] Hooks, Actions and Filters Oh My!
 
DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014
 
Beginner Workshop WCMIA
Beginner Workshop WCMIABeginner Workshop WCMIA
Beginner Workshop WCMIA
 
Basic word press development
Basic word press developmentBasic word press development
Basic word press development
 
Geekaboo presentation 2013 - Brett Napoli
Geekaboo presentation 2013 - Brett NapoliGeekaboo presentation 2013 - Brett Napoli
Geekaboo presentation 2013 - Brett Napoli
 
Organization methods in word press
Organization methods in word pressOrganization methods in word press
Organization methods in word press
 

DIG1108C Lesson 2 Fall 2014

  • 1. Intro to Server-Side Programming Week Two
  • 2. PHP As A Language • PHP can be treated as a distinct language with it’s own rules • It has it’s own vocabulary - words that are familiar to the language • PHP has distinct grammatical rules • Syntax - rules to determine the composition of sentences • Semantics - the meaning and significance of words • Structure - the relationship between words
  • 3. Grammar and Vocaublary • Reserved Words and Keywords: if, else, ifelse; for, foreach, while, do; and, or, xor; public, private, protected • Expressions: semicolon (;), curly braces ({...}) • Arithmetic: addition (+), subtraction (-), multiplication(*) • Comparisons: equality (==), inequalities (!=), ranges (<=) • Special cases: dollar($), braces ([...]), operators (&, |, <<) • User & Built-in Constants: PHP_VERSION, E_ERROR, E_WARNING, E_NOTICE, MY_CONSTANT • User & Built-in Functions: shuffle(), printf(), strlen()
  • 4. The PHP Manual - http://php.net/manual/en/ • In your “assignments” workspace, create a file called “assignment-2.1.md” to work on your answers to the following questions: • Find at least three different methods to get a random value from an array with a built-in function (Look in Array Functions) • What does the built-in md5() function do? What is the default return value? What built-in functions work similarly? • What is another name for “anonymous functions” in PHP and where are they in the manual? When were they added and what was the last feature added? • What is the default value of the “memory_limit” setting in PHP? What value would I set to it in order to allocate ALL memory to PHP? How could I set that value and where would I find that in the manual?
  • 5. Data Types - Literals • Literals are also known as Primitive Values • Representative of fixed values, such as numbers or text • Four scalar types: boolean, integer, float (double) & string • Two compound types: array & object • Three special types: resource, NULL & callable • What makes 1 different from 1.0?
  • 6. Working With Variables • Variables are storage locations with identifiers that contain values • Variables are places to store your literals. Think of a bucket. $a_variable // This is a bucket to hold literals! $a_variable = “some value” // Now the bucket has stuff in it $a_variable = “something else” // The bucket remains, but a new string is put in it • Variables in PHP are always preceded with a dollar sign ($) • Variables are not very useful empty, so they are usually followed with an assignment operator
  • 7. Assignment Operators • An operator accepts one or more literals or variables, performs an operation on them and returns the results, like a calculator. $total = 1 // total is defined as 1 $total = $total + 1 // total is now 2 $total += 2 // total is now 4 (old total plus 2) • Orders of operation and precedence still apply here!
  • 8. Basic “Phrases” • Variables, basic expressions and comments: $david = ‘awesome’; // not entirely true • Basic assignment and arithmetic operators: $counter = 1; $counter = 2; $counter = 1 + 1; $counter += 2; • Getting feedback from PHP: echo $counter; var_dump($counter); var_export($counter);
  • 10. Pulling Files From Git (cont) • Open the project that you forked earlier or fork one now • Grab around 50 lines of PHP from that project that show examples of literals, variables, function calls and other colored (important) things • If there is something that you don’t recognize, note it for later • The goal is to practice “reading” PHP grammar for now