SlideShare une entreprise Scribd logo
1  sur  33
Underground PHP
         
    by Rob Hawkes
   i7872333@bournemouth.ac.uk
The ground rules
What the sessions are
✽   Somewhere to admit lack of
    understanding
✽   Covering areas missed in workshops
✽   Helping you understand programming
    theory – critical!
✽   Focussing on the “why” over “how”
✽   A launch pad for further learning
And what they aren’t

✽   Quick fix for The Station
    •   Will provide examples of when to use techniques in
        context
    •   Will not provide code to copy & paste

✽   Easy
    •   PHP takes time & effort to learn
These go without saying

✽   Provide your own equipment
    •   We might not always be in the labs
    •   I can’t provide individual web space

✽   Don’t piss about
    •   Please only come if you genuinely want to learn
    •   I won’t waste my time or yours
VIVA LA RESISTANCE!
Session 1: The Basics
What we’ll cover


✽   An introduction to PHP
✽   Where to get help when you’re stuck
✽   Best practice when coding
✽   Fundamental knowledge
PHP: An introduction
What is PHP?
✽   Stands for PHP: Hypertext Preprocessor
    •   Yes, a recursive acronym. Funky!

✽   Run directly on the web server
    •   Windows, Linux, and Mac

✽   Makes web pages dynamic
    •   Calculations, database interaction, etc.

✽   Latest version is PHP 5
    •   Introduces features not supported in PHP 4
Basic PHP process

    User's Browser


    Web Server (Apache)




        PHP Engine




     MySQL Database
Where to get help
Online help
✽   Official PHP documentation
    •   php.net

✽   Stack Overflow
    •   stackoverflow.com

✽   SitePoint forums
    •   sitepoint.com/forums

✽   Google
Offline help

✽   Don’t look at me
    •   Would love to but I don’t have the time

✽   Books
    •   PHP and MySQL for Dynamic Web Sites
    •   PHP and MySQL Bible
Best practice
Indentation & spacing


✽   Neat & tidy
✽   Makes code readable
✽   Less prone to error
✽   Easier to debug in future
Indentation & spacing
Unindented                           Indented
<?php                                <?php
$array=array(‘1’,‘2’,‘3’,‘4’,‘5’);   $array = array(‘1’, ‘2’, ‘3’, ‘4’, ‘5’);
$count=count($array);                $count = count($array);
for($i=0;$i<$count;$i++){
if($i==2){                           for ($i = 0; $i < $count; $i++) {
echo $array[$i];                        if ($i == 2) {
}                                           echo $array[$i];
}                                       }
?>                                   }
                                     ?>
Unindented   Indented
Comment everything
✽   // comments a single line
✽   /* text */ comments multiple lines
✽   Helps with learning
✽   Make comments meaningful
    •   Explain in detail exactly what the code does

✽   Saves time when debugging
✽   Will save your arse many times
Naming conventions

✽   camelCase
    •   Always start with a lowercase letter
    •   Capitalise the first letter of any further words

✽   Meaningful names
    •   ShowProfile() rather than function1()
    •   Makes code readable at a glance
Further reading



✽   Zend Framework coding standards
    •   http://framework.zend.com/manual/en/coding-
        standard.html
Fundamental
 knowledge
General syntax

✽   Wrap all PHP within <?php and ?> tags
    •   Tells server that the code within is to be run through
        the PHP system

✽   End every line with a semicolon;
    •   Ok, not every line but enough to use that rule
    •   Lets the PHP system know where a line of code ends
    •   Most rookie errors are caused by forgetting semicolons
General syntax
✽   Use $variables to store data for later
    •   Variables are always preceded with a $ symbol
    •   They can’t begin with a number
    •   Any type of data can be stored inside a variable

✽   Echo and print
    •   Used to output data to the browser
    •   Negligible difference in performance between the two
    •   Most programmers use echo
Data types
Name             Short name      Notes
Boolean          bool            Truth value, either true or false

Integer          int             Whole number (eg. 5)

Floating point   float / double   Decimal fraction (eg. 1.7)

String           str             Series of characters, usually text,
                                 enclosed in quotation marks
Array            arr             Used to store multiple pieces of data
                                 in one place
Assignment operators
Operator   Example         Notes
=          $a = 1+4;       Assigns the left operand (variable) to
                           the value on the right

+=         $a += 5         Adds the value on the right the
                           existing value of $a

-=         $a -= 5         Subtracts the value on the right from
                           the existing value of $a

.=         $a .= ‘Hello’   Appends the value on the right to the
                           existing value of $a, mainly used with
                           strings
Arithmetic operators
Operator   Name             Notes
-$a        Negation         Opposite / reverse of $a

$a + $b    Addition         Sum of $a and $b

$a - $b    Subtraction      Difference of $a and $b

$a * $b    Multiplication   Product of $a and $b

$a / $b    Division         Quotient of $a and $b

$a % $b    Modulus          Remainder of $a divided by $b
Comparison operators
Operator    Name              Notes
$a == $b    Equal             True if $a is equal to $b
$a === $b   Identical         True if $a is equal to $b, and are of
                              the same data type
$a != $b    Not equal         True if $a is not equal to $b

$a !== $b   Not identical     True if $a is not equal to $b, or they
                              are not of the same data type
$a < $b     Less than         True if $a is less than $b

$a > $b     Greater than      True if $a is greater than $b

$a <= $b    Less than or      True if $a is less than or equal to $b
            equal to
$a >= $b    Greater than or   True if $a is greater than or equal to
            equal to          $b
Increment & decrement
Operator   Name             Notes
++$a       Pre-increment    Increase $a by one then return $a

$a++       Post-increment   Return $a then increase $a by one

--$a       Pre-decrement    Decrease $a by one then return $a

$a--       Post-decrement   Return $a then decrease $a by one
Logic operators
Operator     Name   Notes
$a and $b    And    True if both $a and $b are true

$a && $b     And    True if both $a and $b are true

$a or $b     Or     True if $a or $b is true

$a || $b     Or     True if $a or $b is true

$a xor $b    Xor    True if $a or $b is true, but not both

!$a          Not    True if $a is not true
Operator roundup

✽   PHP uses the same operators as most
    major programming languages
✽   = does not mean ‘equal to’
    •   = is used to assign a value
    •   == means ‘equal to’
Further reading
✽   PHP.net data types documentation
    •   http://www.php.net/manual/en/
        language.types.intro.php

✽   PHP.net operator documentation
    •   http://www.php.net/manual/en/
        language.operators.php

✽   PHP.net type comparison tables
    •   http://www.php.net/manual/en/
        types.comparisons.php
Any questions?

Contenu connexe

Tendances (20)

Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Learn PHP Basics
Learn PHP Basics Learn PHP Basics
Learn PHP Basics
 
Introduction to Perl - Day 2
Introduction to Perl - Day 2Introduction to Perl - Day 2
Introduction to Perl - Day 2
 
4.7 Automate Loading Data with Little to No Duplicates!
4.7 Automate Loading Data with Little to No Duplicates!4.7 Automate Loading Data with Little to No Duplicates!
4.7 Automate Loading Data with Little to No Duplicates!
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
 
Introduction to php php++
Introduction to php php++Introduction to php php++
Introduction to php php++
 
Dev traning 2016 basics of PHP
Dev traning 2016   basics of PHPDev traning 2016   basics of PHP
Dev traning 2016 basics of PHP
 
Perl programming language
Perl programming languagePerl programming language
Perl programming language
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Perl Basics with Examples
Perl Basics with ExamplesPerl Basics with Examples
Perl Basics with Examples
 
Introduction to Perl Best Practices
Introduction to Perl Best PracticesIntroduction to Perl Best Practices
Introduction to Perl Best Practices
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
05php
05php05php
05php
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 

En vedette

Learning Sessions #5 Pre Incubator - WindSync
Learning Sessions #5 Pre Incubator - WindSyncLearning Sessions #5 Pre Incubator - WindSync
Learning Sessions #5 Pre Incubator - WindSyncjvielman
 
又一個誤聽 GAE 的悲劇
又一個誤聽 GAE 的悲劇又一個誤聽 GAE 的悲劇
又一個誤聽 GAE 的悲劇Toomore
 
MDN Hackday London - Boot to Gecko: The Future of Mobile
MDN Hackday London - Boot to Gecko: The Future of MobileMDN Hackday London - Boot to Gecko: The Future of Mobile
MDN Hackday London - Boot to Gecko: The Future of MobileRobin Hawkes
 
Karz short presentation deck 12 2016
Karz short presentation deck 12 2016Karz short presentation deck 12 2016
Karz short presentation deck 12 2016Danny Lahav
 
Session2 pl online_course_26_may2011- final
Session2  pl online_course_26_may2011- finalSession2  pl online_course_26_may2011- final
Session2 pl online_course_26_may2011- finalLeslieOflahavan
 
090216 roma iucc_fbcei_dovwiner
090216 roma iucc_fbcei_dovwiner090216 roma iucc_fbcei_dovwiner
090216 roma iucc_fbcei_dovwinerDov Winer
 
WebVisions – ViziCities: Bringing Cities to Life Using Big Data
WebVisions – ViziCities: Bringing Cities to Life Using Big DataWebVisions – ViziCities: Bringing Cities to Life Using Big Data
WebVisions – ViziCities: Bringing Cities to Life Using Big DataRobin Hawkes
 
HTML5 & JavaScript: The Future Now
HTML5 & JavaScript: The Future NowHTML5 & JavaScript: The Future Now
HTML5 & JavaScript: The Future NowRobin Hawkes
 
Bb Security
Bb SecurityBb Security
Bb Securityjustin92
 
Session4 pl online_course_30_september2011
Session4  pl online_course_30_september2011Session4  pl online_course_30_september2011
Session4 pl online_course_30_september2011LeslieOflahavan
 
Boot to Gecko – The Web as a Platform
Boot to Gecko – The Web as a PlatformBoot to Gecko – The Web as a Platform
Boot to Gecko – The Web as a PlatformRobin Hawkes
 
2012.04.05 Learning Sessions #1: CityArtWorks + Mercury
2012.04.05 Learning Sessions #1: CityArtWorks + Mercury2012.04.05 Learning Sessions #1: CityArtWorks + Mercury
2012.04.05 Learning Sessions #1: CityArtWorks + Mercuryjvielman
 
66条禅语,茶具欣赏feeling dhyana words and tea
66条禅语,茶具欣赏feeling dhyana words and tea66条禅语,茶具欣赏feeling dhyana words and tea
66条禅语,茶具欣赏feeling dhyana words and teayangbqada
 

En vedette (20)

Hw fdb(2)
Hw fdb(2)Hw fdb(2)
Hw fdb(2)
 
Learning Sessions #5 Pre Incubator - WindSync
Learning Sessions #5 Pre Incubator - WindSyncLearning Sessions #5 Pre Incubator - WindSync
Learning Sessions #5 Pre Incubator - WindSync
 
又一個誤聽 GAE 的悲劇
又一個誤聽 GAE 的悲劇又一個誤聽 GAE 的悲劇
又一個誤聽 GAE 的悲劇
 
MDN Hackday London - Boot to Gecko: The Future of Mobile
MDN Hackday London - Boot to Gecko: The Future of MobileMDN Hackday London - Boot to Gecko: The Future of Mobile
MDN Hackday London - Boot to Gecko: The Future of Mobile
 
Implikasi Pelaksanaan Undang Undang Desa (161115)
Implikasi Pelaksanaan Undang Undang Desa (161115)Implikasi Pelaksanaan Undang Undang Desa (161115)
Implikasi Pelaksanaan Undang Undang Desa (161115)
 
May 28 2010
May 28 2010May 28 2010
May 28 2010
 
Karz short presentation deck 12 2016
Karz short presentation deck 12 2016Karz short presentation deck 12 2016
Karz short presentation deck 12 2016
 
That's not what he said!
That's not what he said!That's not what he said!
That's not what he said!
 
Session2 pl online_course_26_may2011- final
Session2  pl online_course_26_may2011- finalSession2  pl online_course_26_may2011- final
Session2 pl online_course_26_may2011- final
 
090216 roma iucc_fbcei_dovwiner
090216 roma iucc_fbcei_dovwiner090216 roma iucc_fbcei_dovwiner
090216 roma iucc_fbcei_dovwiner
 
WebVisions – ViziCities: Bringing Cities to Life Using Big Data
WebVisions – ViziCities: Bringing Cities to Life Using Big DataWebVisions – ViziCities: Bringing Cities to Life Using Big Data
WebVisions – ViziCities: Bringing Cities to Life Using Big Data
 
HTML5 & JavaScript: The Future Now
HTML5 & JavaScript: The Future NowHTML5 & JavaScript: The Future Now
HTML5 & JavaScript: The Future Now
 
Helmi Suhaimi
Helmi SuhaimiHelmi Suhaimi
Helmi Suhaimi
 
Bb Security
Bb SecurityBb Security
Bb Security
 
Session4 pl online_course_30_september2011
Session4  pl online_course_30_september2011Session4  pl online_course_30_september2011
Session4 pl online_course_30_september2011
 
Boot to Gecko – The Web as a Platform
Boot to Gecko – The Web as a PlatformBoot to Gecko – The Web as a Platform
Boot to Gecko – The Web as a Platform
 
Talent Development Consulting C P
Talent  Development  Consulting  C PTalent  Development  Consulting  C P
Talent Development Consulting C P
 
2012.04.05 Learning Sessions #1: CityArtWorks + Mercury
2012.04.05 Learning Sessions #1: CityArtWorks + Mercury2012.04.05 Learning Sessions #1: CityArtWorks + Mercury
2012.04.05 Learning Sessions #1: CityArtWorks + Mercury
 
Yahoo pipes
Yahoo pipesYahoo pipes
Yahoo pipes
 
66条禅语,茶具欣赏feeling dhyana words and tea
66条禅语,茶具欣赏feeling dhyana words and tea66条禅语,茶具欣赏feeling dhyana words and tea
66条禅语,茶具欣赏feeling dhyana words and tea
 

Similaire à PHP Underground Session 1: The Basics

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.pdfpkaviya
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation TutorialLorna Mitchell
 
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 Kianphelios
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHPBUDNET
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptxrani marri
 
php app development 1
php app development 1php app development 1
php app development 1barryavery
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Michelangelo van Dam
 
php fundamental
php fundamentalphp fundamental
php fundamentalzalatarunk
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of phppooja bhandari
 
PHP Introduction and Training Material
PHP Introduction and Training MaterialPHP Introduction and Training Material
PHP Introduction and Training MaterialManoj kumar
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perlworr1244
 

Similaire à PHP Underground Session 1: The Basics (20)

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
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
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
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
 
php app development 1
php app development 1php app development 1
php app development 1
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
slidesharenew1
slidesharenew1slidesharenew1
slidesharenew1
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
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
 
05php
05php05php
05php
 
Prersentation
PrersentationPrersentation
Prersentation
 
PHP Introduction and Training Material
PHP Introduction and Training MaterialPHP Introduction and Training Material
PHP Introduction and Training Material
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 

Plus de Robin Hawkes

ViziCities - Lessons Learnt Visualising Real-world Cities in 3D
ViziCities - Lessons Learnt Visualising Real-world Cities in 3DViziCities - Lessons Learnt Visualising Real-world Cities in 3D
ViziCities - Lessons Learnt Visualising Real-world Cities in 3DRobin Hawkes
 
Understanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisationUnderstanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisationRobin Hawkes
 
Calculating building heights using a phone camera
Calculating building heights using a phone cameraCalculating building heights using a phone camera
Calculating building heights using a phone cameraRobin Hawkes
 
Understanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisationUnderstanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisationRobin Hawkes
 
ViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGL
ViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGLViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGL
ViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGLRobin Hawkes
 
Beautiful Data Visualisation & D3
Beautiful Data Visualisation & D3Beautiful Data Visualisation & D3
Beautiful Data Visualisation & D3Robin Hawkes
 
ViziCities: Making SimCity for the Real World
ViziCities: Making SimCity for the Real WorldViziCities: Making SimCity for the Real World
ViziCities: Making SimCity for the Real WorldRobin Hawkes
 
The State of WebRTC
The State of WebRTCThe State of WebRTC
The State of WebRTCRobin Hawkes
 
Bringing Cities to Life Using Big Data & WebGL
Bringing Cities to Life Using Big Data & WebGLBringing Cities to Life Using Big Data & WebGL
Bringing Cities to Life Using Big Data & WebGLRobin Hawkes
 
Mobile App Development - Pitfalls & Helpers
Mobile App Development - Pitfalls & HelpersMobile App Development - Pitfalls & Helpers
Mobile App Development - Pitfalls & HelpersRobin Hawkes
 
Mozilla Firefox: Present and Future - Fluent JS
Mozilla Firefox: Present and Future - Fluent JSMozilla Firefox: Present and Future - Fluent JS
Mozilla Firefox: Present and Future - Fluent JSRobin Hawkes
 
The State of HTML5 Games - Fluent JS
The State of HTML5 Games - Fluent JSThe State of HTML5 Games - Fluent JS
The State of HTML5 Games - Fluent JSRobin Hawkes
 
HTML5 Technologies for Game Development - Web Directions Code
HTML5 Technologies for Game Development - Web Directions CodeHTML5 Technologies for Game Development - Web Directions Code
HTML5 Technologies for Game Development - Web Directions CodeRobin Hawkes
 
MelbJS - Inside Rawkets
MelbJS - Inside RawketsMelbJS - Inside Rawkets
MelbJS - Inside RawketsRobin Hawkes
 
Melbourne Geek Night - Boot to Gecko – The Web as a Platform
Melbourne Geek Night - Boot to Gecko – The Web as a PlatformMelbourne Geek Night - Boot to Gecko – The Web as a Platform
Melbourne Geek Night - Boot to Gecko – The Web as a PlatformRobin Hawkes
 
Hacking with B2G – Web Apps and Customisation
Hacking with B2G – Web Apps and CustomisationHacking with B2G – Web Apps and Customisation
Hacking with B2G – Web Apps and CustomisationRobin Hawkes
 
MDN Hackday London - Open Web Games with HTML5 & JavaScript
MDN Hackday London - Open Web Games with HTML5 & JavaScriptMDN Hackday London - Open Web Games with HTML5 & JavaScript
MDN Hackday London - Open Web Games with HTML5 & JavaScriptRobin Hawkes
 
Geek Meet - Boot to Gecko: The Future of Mobile?
Geek Meet - Boot to Gecko: The Future of Mobile?Geek Meet - Boot to Gecko: The Future of Mobile?
Geek Meet - Boot to Gecko: The Future of Mobile?Robin Hawkes
 
HTML5 Games - Not Just for Gamers
HTML5 Games - Not Just for GamersHTML5 Games - Not Just for Gamers
HTML5 Games - Not Just for GamersRobin Hawkes
 
NY HTML5 - Game Development with HTML5 & JavaScript
NY HTML5 - Game Development with HTML5 & JavaScriptNY HTML5 - Game Development with HTML5 & JavaScript
NY HTML5 - Game Development with HTML5 & JavaScriptRobin Hawkes
 

Plus de Robin Hawkes (20)

ViziCities - Lessons Learnt Visualising Real-world Cities in 3D
ViziCities - Lessons Learnt Visualising Real-world Cities in 3DViziCities - Lessons Learnt Visualising Real-world Cities in 3D
ViziCities - Lessons Learnt Visualising Real-world Cities in 3D
 
Understanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisationUnderstanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisation
 
Calculating building heights using a phone camera
Calculating building heights using a phone cameraCalculating building heights using a phone camera
Calculating building heights using a phone camera
 
Understanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisationUnderstanding cities using ViziCities and 3D data visualisation
Understanding cities using ViziCities and 3D data visualisation
 
ViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGL
ViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGLViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGL
ViziCities: Creating Real-World Cities in 3D using OpenStreetMap and WebGL
 
Beautiful Data Visualisation & D3
Beautiful Data Visualisation & D3Beautiful Data Visualisation & D3
Beautiful Data Visualisation & D3
 
ViziCities: Making SimCity for the Real World
ViziCities: Making SimCity for the Real WorldViziCities: Making SimCity for the Real World
ViziCities: Making SimCity for the Real World
 
The State of WebRTC
The State of WebRTCThe State of WebRTC
The State of WebRTC
 
Bringing Cities to Life Using Big Data & WebGL
Bringing Cities to Life Using Big Data & WebGLBringing Cities to Life Using Big Data & WebGL
Bringing Cities to Life Using Big Data & WebGL
 
Mobile App Development - Pitfalls & Helpers
Mobile App Development - Pitfalls & HelpersMobile App Development - Pitfalls & Helpers
Mobile App Development - Pitfalls & Helpers
 
Mozilla Firefox: Present and Future - Fluent JS
Mozilla Firefox: Present and Future - Fluent JSMozilla Firefox: Present and Future - Fluent JS
Mozilla Firefox: Present and Future - Fluent JS
 
The State of HTML5 Games - Fluent JS
The State of HTML5 Games - Fluent JSThe State of HTML5 Games - Fluent JS
The State of HTML5 Games - Fluent JS
 
HTML5 Technologies for Game Development - Web Directions Code
HTML5 Technologies for Game Development - Web Directions CodeHTML5 Technologies for Game Development - Web Directions Code
HTML5 Technologies for Game Development - Web Directions Code
 
MelbJS - Inside Rawkets
MelbJS - Inside RawketsMelbJS - Inside Rawkets
MelbJS - Inside Rawkets
 
Melbourne Geek Night - Boot to Gecko – The Web as a Platform
Melbourne Geek Night - Boot to Gecko – The Web as a PlatformMelbourne Geek Night - Boot to Gecko – The Web as a Platform
Melbourne Geek Night - Boot to Gecko – The Web as a Platform
 
Hacking with B2G – Web Apps and Customisation
Hacking with B2G – Web Apps and CustomisationHacking with B2G – Web Apps and Customisation
Hacking with B2G – Web Apps and Customisation
 
MDN Hackday London - Open Web Games with HTML5 & JavaScript
MDN Hackday London - Open Web Games with HTML5 & JavaScriptMDN Hackday London - Open Web Games with HTML5 & JavaScript
MDN Hackday London - Open Web Games with HTML5 & JavaScript
 
Geek Meet - Boot to Gecko: The Future of Mobile?
Geek Meet - Boot to Gecko: The Future of Mobile?Geek Meet - Boot to Gecko: The Future of Mobile?
Geek Meet - Boot to Gecko: The Future of Mobile?
 
HTML5 Games - Not Just for Gamers
HTML5 Games - Not Just for GamersHTML5 Games - Not Just for Gamers
HTML5 Games - Not Just for Gamers
 
NY HTML5 - Game Development with HTML5 & JavaScript
NY HTML5 - Game Development with HTML5 & JavaScriptNY HTML5 - Game Development with HTML5 & JavaScript
NY HTML5 - Game Development with HTML5 & JavaScript
 

Dernier

Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Dernier (20)

Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 

PHP Underground Session 1: The Basics

  • 1. Underground PHP  by Rob Hawkes i7872333@bournemouth.ac.uk
  • 3. What the sessions are ✽ Somewhere to admit lack of understanding ✽ Covering areas missed in workshops ✽ Helping you understand programming theory – critical! ✽ Focussing on the “why” over “how” ✽ A launch pad for further learning
  • 4. And what they aren’t ✽ Quick fix for The Station • Will provide examples of when to use techniques in context • Will not provide code to copy & paste ✽ Easy • PHP takes time & effort to learn
  • 5. These go without saying ✽ Provide your own equipment • We might not always be in the labs • I can’t provide individual web space ✽ Don’t piss about • Please only come if you genuinely want to learn • I won’t waste my time or yours
  • 7. Session 1: The Basics
  • 8. What we’ll cover ✽ An introduction to PHP ✽ Where to get help when you’re stuck ✽ Best practice when coding ✽ Fundamental knowledge
  • 10. What is PHP? ✽ Stands for PHP: Hypertext Preprocessor • Yes, a recursive acronym. Funky! ✽ Run directly on the web server • Windows, Linux, and Mac ✽ Makes web pages dynamic • Calculations, database interaction, etc. ✽ Latest version is PHP 5 • Introduces features not supported in PHP 4
  • 11. Basic PHP process User's Browser Web Server (Apache) PHP Engine MySQL Database
  • 12. Where to get help
  • 13. Online help ✽ Official PHP documentation • php.net ✽ Stack Overflow • stackoverflow.com ✽ SitePoint forums • sitepoint.com/forums ✽ Google
  • 14. Offline help ✽ Don’t look at me • Would love to but I don’t have the time ✽ Books • PHP and MySQL for Dynamic Web Sites • PHP and MySQL Bible
  • 16. Indentation & spacing ✽ Neat & tidy ✽ Makes code readable ✽ Less prone to error ✽ Easier to debug in future
  • 17. Indentation & spacing Unindented Indented <?php <?php $array=array(‘1’,‘2’,‘3’,‘4’,‘5’); $array = array(‘1’, ‘2’, ‘3’, ‘4’, ‘5’); $count=count($array); $count = count($array); for($i=0;$i<$count;$i++){ if($i==2){ for ($i = 0; $i < $count; $i++) { echo $array[$i]; if ($i == 2) { } echo $array[$i]; } } ?> } ?>
  • 18. Unindented Indented
  • 19. Comment everything ✽ // comments a single line ✽ /* text */ comments multiple lines ✽ Helps with learning ✽ Make comments meaningful • Explain in detail exactly what the code does ✽ Saves time when debugging ✽ Will save your arse many times
  • 20. Naming conventions ✽ camelCase • Always start with a lowercase letter • Capitalise the first letter of any further words ✽ Meaningful names • ShowProfile() rather than function1() • Makes code readable at a glance
  • 21. Further reading ✽ Zend Framework coding standards • http://framework.zend.com/manual/en/coding- standard.html
  • 23. General syntax ✽ Wrap all PHP within <?php and ?> tags • Tells server that the code within is to be run through the PHP system ✽ End every line with a semicolon; • Ok, not every line but enough to use that rule • Lets the PHP system know where a line of code ends • Most rookie errors are caused by forgetting semicolons
  • 24. General syntax ✽ Use $variables to store data for later • Variables are always preceded with a $ symbol • They can’t begin with a number • Any type of data can be stored inside a variable ✽ Echo and print • Used to output data to the browser • Negligible difference in performance between the two • Most programmers use echo
  • 25. Data types Name Short name Notes Boolean bool Truth value, either true or false Integer int Whole number (eg. 5) Floating point float / double Decimal fraction (eg. 1.7) String str Series of characters, usually text, enclosed in quotation marks Array arr Used to store multiple pieces of data in one place
  • 26. Assignment operators Operator Example Notes = $a = 1+4; Assigns the left operand (variable) to the value on the right += $a += 5 Adds the value on the right the existing value of $a -= $a -= 5 Subtracts the value on the right from the existing value of $a .= $a .= ‘Hello’ Appends the value on the right to the existing value of $a, mainly used with strings
  • 27. Arithmetic operators Operator Name Notes -$a Negation Opposite / reverse of $a $a + $b Addition Sum of $a and $b $a - $b Subtraction Difference of $a and $b $a * $b Multiplication Product of $a and $b $a / $b Division Quotient of $a and $b $a % $b Modulus Remainder of $a divided by $b
  • 28. Comparison operators Operator Name Notes $a == $b Equal True if $a is equal to $b $a === $b Identical True if $a is equal to $b, and are of the same data type $a != $b Not equal True if $a is not equal to $b $a !== $b Not identical True if $a is not equal to $b, or they are not of the same data type $a < $b Less than True if $a is less than $b $a > $b Greater than True if $a is greater than $b $a <= $b Less than or True if $a is less than or equal to $b equal to $a >= $b Greater than or True if $a is greater than or equal to equal to $b
  • 29. Increment & decrement Operator Name Notes ++$a Pre-increment Increase $a by one then return $a $a++ Post-increment Return $a then increase $a by one --$a Pre-decrement Decrease $a by one then return $a $a-- Post-decrement Return $a then decrease $a by one
  • 30. Logic operators Operator Name Notes $a and $b And True if both $a and $b are true $a && $b And True if both $a and $b are true $a or $b Or True if $a or $b is true $a || $b Or True if $a or $b is true $a xor $b Xor True if $a or $b is true, but not both !$a Not True if $a is not true
  • 31. Operator roundup ✽ PHP uses the same operators as most major programming languages ✽ = does not mean ‘equal to’ • = is used to assign a value • == means ‘equal to’
  • 32. Further reading ✽ PHP.net data types documentation • http://www.php.net/manual/en/ language.types.intro.php ✽ PHP.net operator documentation • http://www.php.net/manual/en/ language.operators.php ✽ PHP.net type comparison tables • http://www.php.net/manual/en/ types.comparisons.php