Loading ...
Sorry, an error occurred while loading the content.

OOP in PHP :: Create your first class

Expand Messages
  • Day Dreamer
    Hi, OOP is a blessing to modern programmming languages. It helps you to reuse your code and shorten the time of development. Reusable objects (ie. Classes)
    Message 1 of 1 , Nov 2, 2004
    • 0 Attachment
      Hi,
      OOP is a blessing to modern programmming languages. It helps you to
      reuse your code and shorten the time of development. Reusable objects
      (ie. Classes) enables RAD (Rapid Application Development) environment
      for you. PHP4 also support OOP. But it becomes mature in PHP5.

      Here is a sample for PHP4 to create class and use it.

      <?
      class world
      {
      //a sample method in this class
      function speak($wordtospeak)
      {
      echo $wordtospeak;
      }

      }

      //now use this class
      $wd = new world(); //create and instance of our world class
      $wd->speak("Hello World"); //This will print "Hello World"
      ?>

      In PHP5, classes supports all OOP features like Inheritence,
      overloading etc.

      --August
    Your message has been successfully submitted and would be delivered to recipients shortly.