SlideShare a Scribd company logo
1 of 14
Download to read offline
INTRO TO SERVER SIDE DEVELOPMENT
Week Six
Friday, October 4, 13
General Review
Reference: php.net
Literals:
boolean
integer
float
string
array
object
Variables:
$anything
$any['array']
Expressions
1 + 1 == 2
$a = $b + 1
Control Structures
conditional branches
conditional loops:
while, do-while
for, foreach
Workflow Diagrams:
diamonds: decisions
rectangles: process
arrows: branches
Version Control & Git
Cloud9 IDE:
cloning from Github
sharing workspaces
Friday, October 4, 13
Review - Arrays
An array type is a data type that is meant to describe a
collection of values or variables, each selected by one or
more indices(keys) tha can be computed at run-time of the
program.
By default, the array type in PHP generates computed,
numerical indices, starting with zero, to make a list:
var_dump(array( 'one', 'two', 3, 4, 4.1, 4.2 ));
$list = array(); $list[] = 'one'; $list[] = 'two';
The value for the key can also be specified as any scalar
literal (neither array, object nor resource), often a string
var_dump(array( 'one' => 1, 2 => 'two' )):
$list[4] = 'four'; $list['five dot one'] = 5.1;
Friday, October 4, 13
Control Flow Statements
Control Flow - refers to the order in which the individual
statements, instructions or function calls of an
imperative or declarative program are executed or
evaluated. Execution results in a choice being made as to
which of two or more paths should be followed.
Types of Control Flow statements:
continuation at a different statement (unconditional branch or jump)
execute statements only if some condition is met (conditional branch)
execute statements until some conditional is met(loop, conditional branch)
execute defined statements and return (sub/co-routines, continuations)s
stop executing statements (unconditional halt)
Friday, October 4, 13
Review - Loops
A loop is a sequence of statements which is specified once
but which may be carried out several times in succession, a
specified number of times or indefinitely
Specific number of times:
for ( $count = 0; $count < $max; $count++ ) do_something();
Once per each item in a collection(array):
foreach ( $collection as $item ) do_something();
foreach ($collection as $key => $value ) do_something();
Until some condition is met:
while ( $condition == true ) do_something();
do something(); while ( $condition );
Indefinitely(infinitely):
while ( true ) do_something();
do something(); while ( true);
Friday, October 4, 13
Procedural Programming
Procedural programming is based on specifying the steps the
program must take to reach the desired state.
Procedures, also known as routines, subroutines, methods or
functions contain a series of computational steps to be carried
out. Any given procedure might be called at any point during a
program's execution.
Types of Control Flow statements:
continuation at a different statement (unconditional branch or jump)
execute statements only if some condition is met (conditional branch)
execute statements until some conditional is met(loop, conditional branch)
execute defined statements and return (sub/co-routines, continuations)s
stop executing statements (unconditional halt)
Friday, October 4, 13
Declarations
Unlike variables, functions must be "declared" to use
do_something(); // "calling" an undefined function
!! Fatal Error: function do_something is not defined
The keyword function declares a function
function do_nothing() { }
do_nothing(); // "invoking" a function
Each function can only be declared once:
foreach ( range(1, 10) as $loop )
function once_and_only_once() { }
!! Fatal Error: Cannot redeclare once_and_only_once()
Friday, October 4, 13
Modular Programming
Modular Programming ("top-down design" or "stepwise refinement") is
a software design technique that emphasizes separating the
functionality of a program into independent, interchangeable modules,
such that each contains everything necessary to execute only one
aspect of the desired functionality
Separation of Concerns - one piece at a time. Increasing the
complexity of a system compounds the difficulty of
maintaining it; smaller and simpler components are easier to
maintain
Abstraction - write it once and only once
Encapsulation - everything needed is there
Scoping - doesn't affect other elements
Friday, October 4, 13
Functions
Functions must start with the function keyword, must
contain a valid function identifier (with variables), provide an
optional list of arguments surrounded by parentheses, even
if there are none, and a block of code:
function do_something( $an_argument, $another ) {
// Code goes here
}
Nothing from outside is visible to code in the block
Nothing inside the block is visible outside the function
Pass values into a function as arguments at invocation:
do_something( 'some value', "$another_value );
Friday, October 4, 13
$outside_of_scope = 'outside only';
function do_something( $an_arg, $arg_two = false ) {
$inside_of_scope = 'inside only';
if( $arg_two ) echo $outside_of_scope;
echo $an_arg; // passed in at invocation
return $inside_of_scope; // passed back out
}
do_something( 'now' ); // prints "now"
echo $inside_of_scope; // Notice: Undefined variable
do_something( 'again', true ); // Notice: Undefined variable
Friday, October 4, 13
ASSIGNMENT 6.1
Finding Functions
Friday, October 4, 13
Finding Functions
Pair up, login to Github, login to Cloud9
Open an existing Workspace and find some functions
together
Copy and paste the function definition for each into a
new file called assignment-6.1.md in your assignments
workspace
Identify the name of the function and the names of all of
the arguments with comments; bonus points for
identifying the return value of the function
Find at least three invocations of each function
Friday, October 4, 13
ASSIGNMENT 6.2
Identifying Functions & Scope
Friday, October 4, 13
Functions & Scope
Find at least three functions in the WordPress project
Document them in a new file called assignment-6.2.md
Use the format: path/to/file.php:9999
Identify the name of the function and its arguments with
comments
Identify the in-scope variables by name
Identify the return value of each function
Add and commit your file, push to Github
Friday, October 4, 13

More Related Content

What's hot

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 requireTheCreativedev Blog
 
function in c
function in cfunction in c
function in csubam3
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHPAhmed Swilam
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...anshkhurana01
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c programNishmaNJ
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6Rumman Ansari
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c languageMomenMostafa
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9Rumman Ansari
 
ekb.py - Python VS ...
ekb.py - Python VS ...ekb.py - Python VS ...
ekb.py - Python VS ...it-people
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class웅식 전
 

What's hot (20)

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
 
function in c
function in cfunction in c
function in c
 
Functions
FunctionsFunctions
Functions
 
PHP function
PHP functionPHP function
PHP function
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
Php variables
Php variablesPhp variables
Php variables
 
Functions in PHP
Functions in PHPFunctions in PHP
Functions in PHP
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c program
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
Function (rule in programming)
Function (rule in programming)Function (rule in programming)
Function (rule in programming)
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Storage class
Storage classStorage class
Storage class
 
ekb.py - Python VS ...
ekb.py - Python VS ...ekb.py - Python VS ...
ekb.py - Python VS ...
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class11 2. variable-scope rule,-storage_class
11 2. variable-scope rule,-storage_class
 

Viewers also liked (9)

DIG1108 Lesson 5
DIG1108 Lesson 5DIG1108 Lesson 5
DIG1108 Lesson 5
 
Spanish verbs friends
Spanish verbs friendsSpanish verbs friends
Spanish verbs friends
 
Dig1108 Lesson 3
Dig1108 Lesson 3Dig1108 Lesson 3
Dig1108 Lesson 3
 
DIG1108 Lesson 4
DIG1108 Lesson 4DIG1108 Lesson 4
DIG1108 Lesson 4
 
Live virtual machine migration based on future prediction of resource require...
Live virtual machine migration based on future prediction of resource require...Live virtual machine migration based on future prediction of resource require...
Live virtual machine migration based on future prediction of resource require...
 
Dig1108C Lesson 2
Dig1108C Lesson 2Dig1108C Lesson 2
Dig1108C Lesson 2
 
DIG1108 Lesson 8
DIG1108 Lesson 8DIG1108 Lesson 8
DIG1108 Lesson 8
 
Dig1108 c lesson1
Dig1108 c lesson1Dig1108 c lesson1
Dig1108 c lesson1
 
Separata protoracionalismo
Separata protoracionalismoSeparata protoracionalismo
Separata protoracionalismo
 

Similar to DIG1108 Lesson 6

DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014David Wolfpaw
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1saydin_soft
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Fwdays
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityGeorgePeterBanyard
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Development Approach
Development ApproachDevelopment Approach
Development Approachalexkingorg
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesEric Poe
 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosDivante
 
Php course-in-navimumbai
Php course-in-navimumbaiPhp course-in-navimumbai
Php course-in-navimumbaivibrantuser
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Stephan Schmidt
 

Similar to DIG1108 Lesson 6 (20)

DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014DIG1108C Lesson 6 - Fall 2014
DIG1108C Lesson 6 - Fall 2014
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
 
php AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdfphp AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdf
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"Nikita Popov "What’s new in PHP 8.0?"
Nikita Popov "What’s new in PHP 8.0?"
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Introduction in php part 2
Introduction in php part 2Introduction in php part 2
Introduction in php part 2
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Development Approach
Development ApproachDevelopment Approach
Development Approach
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenarios
 
Php course-in-navimumbai
Php course-in-navimumbaiPhp course-in-navimumbai
Php course-in-navimumbai
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5
 

Recently uploaded

Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 

Recently uploaded (20)

Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 

DIG1108 Lesson 6

  • 1. INTRO TO SERVER SIDE DEVELOPMENT Week Six Friday, October 4, 13
  • 2. General Review Reference: php.net Literals: boolean integer float string array object Variables: $anything $any['array'] Expressions 1 + 1 == 2 $a = $b + 1 Control Structures conditional branches conditional loops: while, do-while for, foreach Workflow Diagrams: diamonds: decisions rectangles: process arrows: branches Version Control & Git Cloud9 IDE: cloning from Github sharing workspaces Friday, October 4, 13
  • 3. Review - Arrays An array type is a data type that is meant to describe a collection of values or variables, each selected by one or more indices(keys) tha can be computed at run-time of the program. By default, the array type in PHP generates computed, numerical indices, starting with zero, to make a list: var_dump(array( 'one', 'two', 3, 4, 4.1, 4.2 )); $list = array(); $list[] = 'one'; $list[] = 'two'; The value for the key can also be specified as any scalar literal (neither array, object nor resource), often a string var_dump(array( 'one' => 1, 2 => 'two' )): $list[4] = 'four'; $list['five dot one'] = 5.1; Friday, October 4, 13
  • 4. Control Flow Statements Control Flow - refers to the order in which the individual statements, instructions or function calls of an imperative or declarative program are executed or evaluated. Execution results in a choice being made as to which of two or more paths should be followed. Types of Control Flow statements: continuation at a different statement (unconditional branch or jump) execute statements only if some condition is met (conditional branch) execute statements until some conditional is met(loop, conditional branch) execute defined statements and return (sub/co-routines, continuations)s stop executing statements (unconditional halt) Friday, October 4, 13
  • 5. Review - Loops A loop is a sequence of statements which is specified once but which may be carried out several times in succession, a specified number of times or indefinitely Specific number of times: for ( $count = 0; $count < $max; $count++ ) do_something(); Once per each item in a collection(array): foreach ( $collection as $item ) do_something(); foreach ($collection as $key => $value ) do_something(); Until some condition is met: while ( $condition == true ) do_something(); do something(); while ( $condition ); Indefinitely(infinitely): while ( true ) do_something(); do something(); while ( true); Friday, October 4, 13
  • 6. Procedural Programming Procedural programming is based on specifying the steps the program must take to reach the desired state. Procedures, also known as routines, subroutines, methods or functions contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution. Types of Control Flow statements: continuation at a different statement (unconditional branch or jump) execute statements only if some condition is met (conditional branch) execute statements until some conditional is met(loop, conditional branch) execute defined statements and return (sub/co-routines, continuations)s stop executing statements (unconditional halt) Friday, October 4, 13
  • 7. Declarations Unlike variables, functions must be "declared" to use do_something(); // "calling" an undefined function !! Fatal Error: function do_something is not defined The keyword function declares a function function do_nothing() { } do_nothing(); // "invoking" a function Each function can only be declared once: foreach ( range(1, 10) as $loop ) function once_and_only_once() { } !! Fatal Error: Cannot redeclare once_and_only_once() Friday, October 4, 13
  • 8. Modular Programming Modular Programming ("top-down design" or "stepwise refinement") is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality Separation of Concerns - one piece at a time. Increasing the complexity of a system compounds the difficulty of maintaining it; smaller and simpler components are easier to maintain Abstraction - write it once and only once Encapsulation - everything needed is there Scoping - doesn't affect other elements Friday, October 4, 13
  • 9. Functions Functions must start with the function keyword, must contain a valid function identifier (with variables), provide an optional list of arguments surrounded by parentheses, even if there are none, and a block of code: function do_something( $an_argument, $another ) { // Code goes here } Nothing from outside is visible to code in the block Nothing inside the block is visible outside the function Pass values into a function as arguments at invocation: do_something( 'some value', "$another_value ); Friday, October 4, 13
  • 10. $outside_of_scope = 'outside only'; function do_something( $an_arg, $arg_two = false ) { $inside_of_scope = 'inside only'; if( $arg_two ) echo $outside_of_scope; echo $an_arg; // passed in at invocation return $inside_of_scope; // passed back out } do_something( 'now' ); // prints "now" echo $inside_of_scope; // Notice: Undefined variable do_something( 'again', true ); // Notice: Undefined variable Friday, October 4, 13
  • 12. Finding Functions Pair up, login to Github, login to Cloud9 Open an existing Workspace and find some functions together Copy and paste the function definition for each into a new file called assignment-6.1.md in your assignments workspace Identify the name of the function and the names of all of the arguments with comments; bonus points for identifying the return value of the function Find at least three invocations of each function Friday, October 4, 13
  • 13. ASSIGNMENT 6.2 Identifying Functions & Scope Friday, October 4, 13
  • 14. Functions & Scope Find at least three functions in the WordPress project Document them in a new file called assignment-6.2.md Use the format: path/to/file.php:9999 Identify the name of the function and its arguments with comments Identify the in-scope variables by name Identify the return value of each function Add and commit your file, push to Github Friday, October 4, 13