SlideShare a Scribd company logo
1 of 19
Download to read offline
EdiPHP
The Students PHP meetup




         @EdiPHP
    http://bit.ly/EdiPHP
Structure of Program
●   Syntax
    –   Code between <?php tags ?>
    –   Statements end with “;”
    –   Comments
         ●
             // Single line
         ●
             /* Multi line */
●   Sample
    –   <?php echo “Hello, world”; ?>

                                     @EdiPHP
                                http://bit.ly/EdiPHP
Data Types
●   Boolean – True/False
●   Int – signed numeric integer
●   Float – floating-point
●   String – a collection of binary data
        –   Note Quotes: “this” is different from 'this'
                 ●   A bit.




                                   @EdiPHP
                              http://bit.ly/EdiPHP
Variables
●   Starts with $ sign
    –   Followed with a letter or “_”
●   Dynamically typed
    –   <?php $foobar = “barfoo”; $foobar = 1; $foobar =
        true; ?>
●   Defining if a variable exists
    –   isset($var)


                                 @EdiPHP
                            http://bit.ly/EdiPHP
Arrays
●   Can be constructed following ways:
●
    $var = Array(1,2,3,4,5,6);
●
    $var = Array(‘cat’ => ‘lolcat’, 0 => 4);
●   Or:
          $var = Array();
          $var[] = 'A';
          $var[] = 'B';
●
    Is equivalent to $var = Array (‘A’, ‘B’, ‘c’);
          $var[] = 'c';




                                  @EdiPHP
                             http://bit.ly/EdiPHP
Operators
●   Standard ones (+,-,/,*)
●   Comparison (==,>=, <=,!=, ===, !==)
●   Concatenation .
    –   “foo”.”bar” == “foobar”
●   What happens if you do:
    –   “2” + 5



                                @EdiPHP
                           http://bit.ly/EdiPHP
Loops
●   For
     –   for ($i=0; $i < 4; $i++) { echo $i; }
●   While
     –   while (true) { destroyTheUniverse(); }
●   Do .. while
     –   do { destroyTheUniverse(); } while (false);
●   Foreach
     –   foreach ($arr = Array(‘a’ => ‘b’, ‘c’ => ‘d’) as $key =>
         $value) { echo $key.$value; }
                                    @EdiPHP
                               http://bit.ly/EdiPHP
Functions
●   Begin with reserved word “f u n ct ion ”
●   Can have 0 or more formal parameters
●   Can have optional parameters:
    <?php
    function foobar ($reqParam, $optParam = “bar”)
    {
      echo $reqParam.’ foo’.$optParam;
    }
    ?>

                                  @EdiPHP
                             http://bit.ly/EdiPHP
OOP
●   PHP has objects like java, cpp does
●
    Reserved word for class is “class”
●   Have good old public, private, etc. and static,
    final, etc. methods




                            @EdiPHP
                       http://bit.ly/EdiPHP
Structure of a class
<?
class foobar
{
    private $privVar = 15;
    public function getPrivVar ()
    {
        return $this->privVar;
    }
}
                                      @EdiPHP
?>                               http://bit.ly/EdiPHP
Real world examples (1)
●       Bad word filtering
        –   A function that converts all occurrences of
            “LOLSoc” to “CompSoc”
<?php
    function filterBadWords($input)
    {
        return str_replace(‘LOLSoc’, ‘CompSoc’, $input);
    }
?>
                                     @EdiPHP
                                http://bit.ly/EdiPHP
Real World examples (2)
    ●    Calculating sum of digits in array
<?php

$arr = array(1,2,3,4,5,6,7,-6);

function sumDigits ($a)

{

    $sum = 0;

    for ($i=0; $i < count($a); $i++)

    {

        $sum += $a[$i];

    }

    return $sum;
                                            @EdiPHP
}
                                       http://bit.ly/EdiPHP
Real World Examples (3)
●   Creating a class society
    –   Which has a name
●   That is a useless class, though, that's the best
    that fits into slide :)




                                @EdiPHP
                           http://bit.ly/EdiPHP
<?php
         Real World Examples (3)
 Class society
                                          function setName($name)
 {                                        {
     private $_name;                          $this->$_name = $name;
     function setName($name)
                                              return $this;
                                          }
     {


         $this->$_name = $name;




                                          public function getName()
         return $this;


     }


     public function getName()            {
     {
                                            return $this->getName();
                                          }
         return $this->getName();


     }


     public function __construct($name)


     {


         $this->setName($name);


     }


 }
                                                      @EdiPHP
?>                                               http://bit.ly/EdiPHP
Extending the previous
               example
    ●   Making it echo
    ●   Add following method to class:
public function __toString()

{

    echo $this->getName();

}




                                    @EdiPHP
                               http://bit.ly/EdiPHP
A bit about static methods
    ●    To define a static function:
public static function foobar ()
{
        return “foobar”;
}
    ●    To call a static function
               –   From outside the class scope: className::function()
               –   From inside the class: self::function()

                                         @EdiPHP
                                    http://bit.ly/EdiPHP
Questions




      @EdiPHP
 http://bit.ly/EdiPHP
Tasks
●   Yes, we have them.
●   Please try to do them until next meetup, where
    we'll discuss the solutions.




                           @EdiPHP
                      http://bit.ly/EdiPHP
EdiPHP
The Students PHP meetup




         @EdiPHP
    http://bit.ly/EdiPHP

More Related Content

What's hot

php 2 Function creating, calling, PHP built-in function
php 2 Function creating, calling,PHP built-in functionphp 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling, PHP built-in functiontumetr1
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboardsDenis Ristic
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)Win Yu
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Bozhidar Boshnakov
 
Introduction to web and php mysql
Introduction to web and php mysqlIntroduction to web and php mysql
Introduction to web and php mysqlProgrammer Blog
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netProgrammer Blog
 
Shell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaShell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaEdureka!
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Prof. Wim Van Criekinge
 

What's hot (20)

PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
php 2 Function creating, calling, PHP built-in function
php 2 Function creating, calling,PHP built-in functionphp 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling, PHP built-in function
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
 
Introduction in php part 2
Introduction in php part 2Introduction in php part 2
Introduction in php part 2
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
 
Introduction to web and php mysql
Introduction to web and php mysqlIntroduction to web and php mysql
Introduction to web and php mysql
 
Php my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.netPhp my sql - functions - arrays - tutorial - programmerblog.net
Php my sql - functions - arrays - tutorial - programmerblog.net
 
Shell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaShell Scripting Tutorial | Edureka
Shell Scripting Tutorial | Edureka
 
Subroutines
SubroutinesSubroutines
Subroutines
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 

Viewers also liked

Web Based Workforce Training Presentation
Web Based Workforce Training PresentationWeb Based Workforce Training Presentation
Web Based Workforce Training Presentationlstansbury
 
Task 2
Task 2Task 2
Task 2EdiPHP
 
Task 03
Task 03Task 03
Task 03EdiPHP
 
Why Renting Isn't Throwing Money Away | Scott Dilloff
Why Renting Isn't Throwing Money Away | Scott DilloffWhy Renting Isn't Throwing Money Away | Scott Dilloff
Why Renting Isn't Throwing Money Away | Scott DilloffScott Dilloff
 
01 - First Meetup
01 - First Meetup01 - First Meetup
01 - First MeetupEdiPHP
 
03 - Third Meetup
03 - Third Meetup03 - Third Meetup
03 - Third MeetupEdiPHP
 
Task 1
Task 1Task 1
Task 1EdiPHP
 
Managing Religious Tourism Abstracts
Managing Religious Tourism   AbstractsManaging Religious Tourism   Abstracts
Managing Religious Tourism Abstractseon
 
Ppt Ingles
Ppt InglesPpt Ingles
Ppt Inglesvalef94
 
Trabajo Excel Mate
Trabajo Excel MateTrabajo Excel Mate
Trabajo Excel Matevalef94
 
Collaborative Learning Solutions
Collaborative Learning SolutionsCollaborative Learning Solutions
Collaborative Learning SolutionsMaartenGKN
 

Viewers also liked (18)

Web Based Workforce Training Presentation
Web Based Workforce Training PresentationWeb Based Workforce Training Presentation
Web Based Workforce Training Presentation
 
ACTIVIDAD 2
ACTIVIDAD 2ACTIVIDAD 2
ACTIVIDAD 2
 
Task 2
Task 2Task 2
Task 2
 
Task 03
Task 03Task 03
Task 03
 
Why Renting Isn't Throwing Money Away | Scott Dilloff
Why Renting Isn't Throwing Money Away | Scott DilloffWhy Renting Isn't Throwing Money Away | Scott Dilloff
Why Renting Isn't Throwing Money Away | Scott Dilloff
 
Lucky
LuckyLucky
Lucky
 
01 - First Meetup
01 - First Meetup01 - First Meetup
01 - First Meetup
 
03 - Third Meetup
03 - Third Meetup03 - Third Meetup
03 - Third Meetup
 
Task 1
Task 1Task 1
Task 1
 
Let's Order TACOS!
Let's Order TACOS!Let's Order TACOS!
Let's Order TACOS!
 
zellers
zellerszellers
zellers
 
Tornadoes keynote1
Tornadoes keynote1Tornadoes keynote1
Tornadoes keynote1
 
Fit4 Business
Fit4 BusinessFit4 Business
Fit4 Business
 
Historical Development Patterns
Historical Development PatternsHistorical Development Patterns
Historical Development Patterns
 
Managing Religious Tourism Abstracts
Managing Religious Tourism   AbstractsManaging Religious Tourism   Abstracts
Managing Religious Tourism Abstracts
 
Ppt Ingles
Ppt InglesPpt Ingles
Ppt Ingles
 
Trabajo Excel Mate
Trabajo Excel MateTrabajo Excel Mate
Trabajo Excel Mate
 
Collaborative Learning Solutions
Collaborative Learning SolutionsCollaborative Learning Solutions
Collaborative Learning Solutions
 

Similar to 02 - Second meetup

OOP is more than Cars and Dogs
OOP is more than Cars and Dogs OOP is more than Cars and Dogs
OOP is more than Cars and Dogs Chris Tankersley
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7ZendVN
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3Jeremy Coates
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
Elements of Functional Programming in PHP
Elements of Functional Programming in PHPElements of Functional Programming in PHP
Elements of Functional Programming in PHPJarek Jakubowski
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation TutorialLorna Mitchell
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolveXSolve
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance TriviaNikita Popov
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptxThắng It
 
08 Advanced PHP #burningkeyboards
08 Advanced PHP #burningkeyboards08 Advanced PHP #burningkeyboards
08 Advanced PHP #burningkeyboardsDenis Ristic
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHPNick Belhomme
 

Similar to 02 - Second meetup (20)

OOP is more than Cars and Dogs
OOP is more than Cars and Dogs OOP is more than Cars and Dogs
OOP is more than Cars and Dogs
 
OOP
OOPOOP
OOP
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Elements of Functional Programming in PHP
Elements of Functional Programming in PHPElements of Functional Programming in PHP
Elements of Functional Programming in PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance Trivia
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx06-classes.ppt (copy).pptx
06-classes.ppt (copy).pptx
 
Intro to PHP
Intro to PHPIntro to PHP
Intro to PHP
 
08 Advanced PHP #burningkeyboards
08 Advanced PHP #burningkeyboards08 Advanced PHP #burningkeyboards
08 Advanced PHP #burningkeyboards
 
Modern php
Modern phpModern php
Modern php
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHP
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 

Recently uploaded

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

02 - Second meetup

  • 1. EdiPHP The Students PHP meetup @EdiPHP http://bit.ly/EdiPHP
  • 2. Structure of Program ● Syntax – Code between <?php tags ?> – Statements end with “;” – Comments ● // Single line ● /* Multi line */ ● Sample – <?php echo “Hello, world”; ?> @EdiPHP http://bit.ly/EdiPHP
  • 3. Data Types ● Boolean – True/False ● Int – signed numeric integer ● Float – floating-point ● String – a collection of binary data – Note Quotes: “this” is different from 'this' ● A bit. @EdiPHP http://bit.ly/EdiPHP
  • 4. Variables ● Starts with $ sign – Followed with a letter or “_” ● Dynamically typed – <?php $foobar = “barfoo”; $foobar = 1; $foobar = true; ?> ● Defining if a variable exists – isset($var) @EdiPHP http://bit.ly/EdiPHP
  • 5. Arrays ● Can be constructed following ways: ● $var = Array(1,2,3,4,5,6); ● $var = Array(‘cat’ => ‘lolcat’, 0 => 4); ● Or: $var = Array(); $var[] = 'A'; $var[] = 'B'; ● Is equivalent to $var = Array (‘A’, ‘B’, ‘c’); $var[] = 'c'; @EdiPHP http://bit.ly/EdiPHP
  • 6. Operators ● Standard ones (+,-,/,*) ● Comparison (==,>=, <=,!=, ===, !==) ● Concatenation . – “foo”.”bar” == “foobar” ● What happens if you do: – “2” + 5 @EdiPHP http://bit.ly/EdiPHP
  • 7. Loops ● For – for ($i=0; $i < 4; $i++) { echo $i; } ● While – while (true) { destroyTheUniverse(); } ● Do .. while – do { destroyTheUniverse(); } while (false); ● Foreach – foreach ($arr = Array(‘a’ => ‘b’, ‘c’ => ‘d’) as $key => $value) { echo $key.$value; } @EdiPHP http://bit.ly/EdiPHP
  • 8. Functions ● Begin with reserved word “f u n ct ion ” ● Can have 0 or more formal parameters ● Can have optional parameters: <?php function foobar ($reqParam, $optParam = “bar”) { echo $reqParam.’ foo’.$optParam; } ?> @EdiPHP http://bit.ly/EdiPHP
  • 9. OOP ● PHP has objects like java, cpp does ● Reserved word for class is “class” ● Have good old public, private, etc. and static, final, etc. methods @EdiPHP http://bit.ly/EdiPHP
  • 10. Structure of a class <? class foobar { private $privVar = 15; public function getPrivVar () { return $this->privVar; } } @EdiPHP ?> http://bit.ly/EdiPHP
  • 11. Real world examples (1) ● Bad word filtering – A function that converts all occurrences of “LOLSoc” to “CompSoc” <?php function filterBadWords($input) { return str_replace(‘LOLSoc’, ‘CompSoc’, $input); } ?> @EdiPHP http://bit.ly/EdiPHP
  • 12. Real World examples (2) ● Calculating sum of digits in array <?php $arr = array(1,2,3,4,5,6,7,-6); function sumDigits ($a) { $sum = 0; for ($i=0; $i < count($a); $i++) { $sum += $a[$i]; } return $sum; @EdiPHP } http://bit.ly/EdiPHP
  • 13. Real World Examples (3) ● Creating a class society – Which has a name ● That is a useless class, though, that's the best that fits into slide :) @EdiPHP http://bit.ly/EdiPHP
  • 14. <?php Real World Examples (3) Class society function setName($name) { { private $_name; $this->$_name = $name; function setName($name) return $this; } { $this->$_name = $name; public function getName() return $this; } public function getName() { { return $this->getName(); } return $this->getName(); } public function __construct($name) { $this->setName($name); } } @EdiPHP ?> http://bit.ly/EdiPHP
  • 15. Extending the previous example ● Making it echo ● Add following method to class: public function __toString() { echo $this->getName(); } @EdiPHP http://bit.ly/EdiPHP
  • 16. A bit about static methods ● To define a static function: public static function foobar () { return “foobar”; } ● To call a static function – From outside the class scope: className::function() – From inside the class: self::function() @EdiPHP http://bit.ly/EdiPHP
  • 17. Questions @EdiPHP http://bit.ly/EdiPHP
  • 18. Tasks ● Yes, we have them. ● Please try to do them until next meetup, where we'll discuss the solutions. @EdiPHP http://bit.ly/EdiPHP
  • 19. EdiPHP The Students PHP meetup @EdiPHP http://bit.ly/EdiPHP