php1 (1)

Embed Size (px)

Citation preview

  • 8/10/2019 php1 (1)

    1/48

    Introduction to PHP

  • 8/10/2019 php1 (1)

    2/48

    PHP

    Server-side scripting language useful for writing CGI

    Began as online tools by Rasmus erfdorf! PHP " Personal Home Page tools

    ! Bottom-up development# $as become e%tremely popular today Somew$at li&e C but muc$ $ig$er level# ''P model was added later

    (specially wit$ )pac$e*inu%*+yS,

    Runs on bot$ ni% and .indows platforms# wit$ most web servers

    sed today wit$ many commercial sites

    )vailable for free! $ttp/**www0p$p0net

    ! 1ocumentation and many resources available online I prefer t$e online documentation# easy to searc$ 2several +b as a

    single large H3+ file4

  • 8/10/2019 php1 (1)

    3/48

    Simple PHP Script

    Consider t$e following H3+ file# e%ample0$tml/

    5$tml6

    5$ead6

    5title6+y Page5*title6

    5*$ead6

    5body6

    5p6Hello world75*p6

    5*body6

    5*$tml6

  • 8/10/2019 php1 (1)

    4/48

    Simple PHP Script

    Here is an e8uivalent PHP script0 PHP files $ave t$e e%tension 90p$p: and maycontain bot$ H3+ and PHP code# w$ic$ is enclosed inside 5;p$p code ;6tags# or alternately 5; code ;6 2if supported4

    5$tml6

    5$ead6

    5title6+y Page5*title65*$ead6

    5body6

    5;p$p

    print295p6$ello world75*p6:4 or t$e empty string 9:

    Common novice mista&e/ Oorgetting t$e J

  • 8/10/2019 php1 (1)

    10/48

    ariables

    Interpreted< consider t$e following/

    J% " =

    ! (%/

    Jarr>U " 9$ello:>>>

  • 8/10/2019 php1 (1)

    41/48

    In$eritance

    'perates li&e you would e%pectclass foo

    public function printItem2Jstring4

    ec$o TOoo/ T 0 Jstring 0 T5P6Tname . "\n"; }

  • 8/10/2019 php1 (1)

    45/48

    )bstract Classes

    )bstract classes cannot be instantiated< abstract met$ods cannot be

    implemented in a subclass

    abstract class )bstractClass

    ** Oorce (%tending class to define t$is met$od

    abstract protected function getalue24