Object Oriented PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Water Cooler v2

    Object Oriented PHP

    I am new to PHP, just one day new. But I am otherwise a seasoned
    programmer on many other languages like C, VB 6, C#, VB.NET, Win32
    platform and have some tiny bit experience in MFC, C++, Python.

    All the tutorials I read so far about PHP contain procedural examples.
    I haven't yet come accross a tutorial on the object oriented PHP. Could
    someone point me to one?

  • Dikkie Dik

    #2
    Re: Object Oriented PHP

    Not a tutorial, but an example:


    Water Cooler v2 wrote:[color=blue]
    > I am new to PHP, just one day new. But I am otherwise a seasoned
    > programmer on many other languages like C, VB 6, C#, VB.NET, Win32
    > platform and have some tiny bit experience in MFC, C++, Python.
    >
    > All the tutorials I read so far about PHP contain procedural examples.
    > I haven't yet come accross a tutorial on the object oriented PHP. Could
    > someone point me to one?
    >[/color]

    Comment

    • Water Cooler v2

      #3
      Re: Object Oriented PHP

      I've seen the C++ scope resolution operator used in some place in PHP
      code. I do not recall where I saw it.

      What's that (::) for? Does it have the same use as in C++?

      Comment

      • NC

        #4
        Re: Object Oriented PHP

        Water Cooler v2 wrote:[color=blue]
        >
        > All the tutorials I read so far about PHP contain procedural examples.
        > I haven't yet come accross a tutorial on the object oriented PHP. Could
        > someone point me to one?[/color]

        Start with the Manual:




        Note that there are differences between PHP 4 and PHP 5 when it comes
        to OO syntax.

        Cheers,
        NC

        Comment

        • NC

          #5
          Re: Object Oriented PHP

          Water Cooler v2 wrote:[color=blue]
          >
          > What's that (::) for? Does it have the same use as in C++?[/color]

          It's all in the Manual:

          PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.



          Cheers,
          NC

          Comment

          • Water Cooler v2

            #6
            Re: Object Oriented PHP

            Thanks very much. :-)

            Comment

            • william.clarke

              #7
              Re: Object Oriented PHP


              Water Cooler v2 wrote:[color=blue]
              > Thanks very much. :-)[/color]

              Here's an OO versus Procedural example of making a MySQLi connection



              Comment

              • Henk Verhoeven

                #8
                Re: Object Oriented PHP

                Water Cooler v2 wrote:
                [color=blue]
                > Thanks very much. :-)
                >[/color]
                You can olso read

                Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

                The thread "PHP Dynamic Database Code" started by josh.kuo@gmail. com on
                Fri, 9 Jun 2006 23:13:21 +0000 (UTC) (from which i have the above urls)
                may also be interesting.

                Once you have a reasonable understanding of the basics of OOP, you could
                take a look at the examples/turorial of phpPeanuts, experiment with it
                and dig into its code using the hypercode browsers to try to understand
                how the framework works. It's very OO ;-)

                Greetings,

                Henk Verhoeven,
                www.phpPeanuts.org.

                Comment

                • NC

                  #9
                  Re: Object Oriented PHP

                  427SOHC wrote:[color=blue]
                  >
                  > If I haven't worked with OOP much would PHP be a safe
                  > starting point, or is there a better programming language
                  > to start with?[/color]

                  If you haven't worked with OOP before, start by learning OOP in the
                  language you otherwise know well. Once you understand the basic
                  concepts (encapsulation, inheritance, polymorphism, etc.), you will be
                  able to ask intelligent questions about how those concepts are
                  implemented in other languages.

                  Also, note that PHP 4 and PHP 5 have different object models; the one
                  in PHP 5 is more in line with what you find in other languages, while
                  the one in PHP 4 is simpler, but more restrictive.

                  Cheers,
                  NC

                  Comment

                  • Tony Marston

                    #10
                    Re: Object Oriented PHP


                    "NC" <nc@iname.com > wrote in message
                    news:1151127795 .486389.113090@ b68g2000cwa.goo glegroups.com.. .[color=blue]
                    > 427SOHC wrote:[color=green]
                    >>
                    >> If I haven't worked with OOP much would PHP be a safe
                    >> starting point, or is there a better programming language
                    >> to start with?[/color]
                    >
                    > If you haven't worked with OOP before, start by learning OOP in the
                    > language you otherwise know well. Once you understand the basic
                    > concepts (encapsulation, inheritance, polymorphism, etc.), you will be
                    > able to ask intelligent questions about how those concepts are
                    > implemented in other languages.
                    >
                    > Also, note that PHP 4 and PHP 5 have different object models; the one
                    > in PHP 5 is more in line with what you find in other languages, while
                    > the one in PHP 4 is simpler, but more restrictive.[/color]

                    "More restrictive" is a point of view. It is possible to write OO code in
                    PHP 4 that also runs in PHP 5, as I have proved with my sample application
                    and later my full-blown framework.

                    AFAIAC the extra OO features in PHP 5 are nothing more than eye candy as
                    they do not provide any additional functionality which is worthy of merit.
                    They were only included to appease the OO purists.

                    --
                    Tony Marston
                    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL

                    Build apps faster with Rapid Application Development using open-source RAD tools, modern RAD frameworks, and rapid application design methods.



                    Comment

                    • Jerry Stuckle

                      #11
                      Re: Object Oriented PHP

                      Tony Marston wrote:[color=blue]
                      > "NC" <nc@iname.com > wrote in message
                      > news:1151127795 .486389.113090@ b68g2000cwa.goo glegroups.com.. .
                      >[color=green]
                      >>427SOHC wrote:
                      >>[color=darkred]
                      >>>If I haven't worked with OOP much would PHP be a safe
                      >>>starting point, or is there a better programming language
                      >>>to start with?[/color]
                      >>
                      >>If you haven't worked with OOP before, start by learning OOP in the
                      >>language you otherwise know well. Once you understand the basic
                      >>concepts (encapsulation, inheritance, polymorphism, etc.), you will be
                      >>able to ask intelligent questions about how those concepts are
                      >>implemented in other languages.
                      >>
                      >>Also, note that PHP 4 and PHP 5 have different object models; the one
                      >>in PHP 5 is more in line with what you find in other languages, while
                      >>the one in PHP 4 is simpler, but more restrictive.[/color]
                      >
                      >
                      > "More restrictive" is a point of view. It is possible to write OO code in
                      > PHP 4 that also runs in PHP 5, as I have proved with my sample application
                      > and later my full-blown framework.
                      >
                      > AFAIAC the extra OO features in PHP 5 are nothing more than eye candy as
                      > they do not provide any additional functionality which is worthy of merit.
                      > They were only included to appease the OO purists.
                      >[/color]

                      Actually, things like private declarations are very important. They are
                      unimportant only to those who don't understand OO programming - or those who are
                      sloppy in their implementations .



                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Tony Marston

                        #12
                        Re: Object Oriented PHP


                        "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                        news:25Sdne4XpP 1UCADZnZ2dnUVZ_ vmdnZ2d@comcast .com...[color=blue]
                        > Tony Marston wrote:[color=green]
                        >> "NC" <nc@iname.com > wrote in message
                        >> news:1151127795 .486389.113090@ b68g2000cwa.goo glegroups.com.. .
                        >>[color=darkred]
                        >>>427SOHC wrote:
                        >>>
                        >>>>If I haven't worked with OOP much would PHP be a safe
                        >>>>starting point, or is there a better programming language
                        >>>>to start with?
                        >>>
                        >>>If you haven't worked with OOP before, start by learning OOP in the
                        >>>language you otherwise know well. Once you understand the basic
                        >>>concepts (encapsulation, inheritance, polymorphism, etc.), you will be
                        >>>able to ask intelligent questions about how those concepts are
                        >>>implemente d in other languages.
                        >>>
                        >>>Also, note that PHP 4 and PHP 5 have different object models; the one
                        >>>in PHP 5 is more in line with what you find in other languages, while
                        >>>the one in PHP 4 is simpler, but more restrictive.[/color]
                        >>
                        >>
                        >> "More restrictive" is a point of view. It is possible to write OO code in
                        >> PHP 4 that also runs in PHP 5, as I have proved with my sample
                        >> application and later my full-blown framework.
                        >>
                        >> AFAIAC the extra OO features in PHP 5 are nothing more than eye candy as
                        >> they do not provide any additional functionality which is worthy of
                        >> merit. They were only included to appease the OO purists.
                        >>[/color]
                        >
                        > Actually, things like private declarations are very important. They are
                        > unimportant only to those who don't understand OO programming - or those
                        > who are sloppy in their implementations .[/color]

                        You don't *need* private declarations. Code will work just as well without
                        them.

                        --
                        Tony Marston

                        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL

                        Build apps faster with Rapid Application Development using open-source RAD tools, modern RAD frameworks, and rapid application design methods.




                        Comment

                        • David Haynes

                          #13
                          Re: Object Oriented PHP

                          Tony Marston wrote:[color=blue]
                          > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message[color=green]
                          >> Actually, things like private declarations are very important. They are
                          >> unimportant only to those who don't understand OO programming - or those
                          >> who are sloppy in their implementations .[/color]
                          >
                          > You don't *need* private declarations. Code will work just as well without
                          > them.
                          >[/color]

                          What the heck! Let's just throw away multiply and divide. We don't
                          *need* them. We can just use add and subtract.

                          Heck! Why do we need subtract? We can just add negative values.

                          Hey! Assembler works well without private declarations. Let's just pitch
                          PHP all together.

                          The point is that constructs are added to language to assist in the
                          functionality and maintainability of programs written in that language.
                          The introduction of private and protected adds to the maintainability
                          both through its inherent protection capabilities and its clarity of
                          intent for the maintainer.

                          Now if PHP could just get polymorphism...

                          -david-

                          Comment

                          • IchBin

                            #14
                            Re: Object Oriented PHP

                            David Haynes wrote:[color=blue]
                            > Tony Marston wrote:[color=green]
                            >> "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message[color=darkred]
                            >>> Actually, things like private declarations are very important. They
                            >>> are unimportant only to those who don't understand OO programming -
                            >>> or those who are sloppy in their implementations .[/color]
                            >>
                            >> You don't *need* private declarations. Code will work just as well
                            >> without them.
                            >>[/color]
                            >
                            > What the heck! Let's just throw away multiply and divide. We don't
                            > *need* them. We can just use add and subtract.
                            >
                            > Heck! Why do we need subtract? We can just add negative values.
                            >
                            > Hey! Assembler works well without private declarations. Let's just pitch
                            > PHP all together.
                            >
                            > The point is that constructs are added to language to assist in the
                            > functionality and maintainability of programs written in that language.
                            > The introduction of private and protected adds to the maintainability
                            > both through its inherent protection capabilities and its clarity of
                            > intent for the maintainer.
                            >
                            > Now if PHP could just get polymorphism...
                            >
                            > -david-
                            >[/color]

                            Sorry I am new to PHP but use Java. My question is how can you have a
                            OOP Language and not have polymorphic features. Sorry, I have not gotten
                            up to par on PHP yet.

                            Thanks in Advance...
                            IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
                            _______________ _______________ _______________ _______________ ______________

                            'If there is one, Knowledge is the "Fountain of Youth"'
                            -William E. Taylor, Regular Guy (1952-)

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: Object Oriented PHP

                              IchBin wrote:[color=blue]
                              > David Haynes wrote:
                              >[color=green]
                              >> Tony Marston wrote:
                              >>[color=darkred]
                              >>> "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                              >>>
                              >>>> Actually, things like private declarations are very important. They
                              >>>> are unimportant only to those who don't understand OO programming -
                              >>>> or those who are sloppy in their implementations .
                              >>>
                              >>>
                              >>> You don't *need* private declarations. Code will work just as well
                              >>> without them.
                              >>>[/color]
                              >>
                              >> What the heck! Let's just throw away multiply and divide. We don't
                              >> *need* them. We can just use add and subtract.
                              >>
                              >> Heck! Why do we need subtract? We can just add negative values.
                              >>
                              >> Hey! Assembler works well without private declarations. Let's just
                              >> pitch PHP all together.
                              >>
                              >> The point is that constructs are added to language to assist in the
                              >> functionality and maintainability of programs written in that
                              >> language. The introduction of private and protected adds to the
                              >> maintainability both through its inherent protection capabilities and
                              >> its clarity of intent for the maintainer.
                              >>
                              >> Now if PHP could just get polymorphism...
                              >>
                              >> -david-
                              >>[/color]
                              >
                              > Sorry I am new to PHP but use Java. My question is how can you have a
                              > OOP Language and not have polymorphic features. Sorry, I have not gotten
                              > up to par on PHP yet.
                              >
                              > Thanks in Advance...
                              > IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
                              > _______________ _______________ _______________ _______________ ______________
                              >
                              > 'If there is one, Knowledge is the "Fountain of Youth"'
                              > -William E. Taylor, Regular Guy (1952-)[/color]

                              PHP does have some polymorphic-like abilities, but that's because of the untyped
                              nature of the variables.

                              PHP is getting better in it's OO aspects, but I doubt it will ever be quite like
                              Java. There's just a basic difference between languages with typed and untyped
                              variables.


                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...