Friday, April 26, 2013

Beginner's tutorial for object oriented PHP

Object Oriented PHP is an efficient way to build a website that allows developers to scale the project much easier. At first glance, it appears that there is no reason to set up your php page this way. For simple tasks, it uses more code, but for a large project the opposite is true. Primarily, because you can reuse your class and methods inside. You can also extend the class to take on traits of other classes. In tradition php, one might print out hello world simply by typing ...


echo "hello world";

The way to set it up as an object oriented program would be the following:

<?php

class HelloWorld {

public function test() {

echo "hello world";

}


}

$var1 = new HelloWorld;
$var1->test();

?>

1 comment:

  1. Hi,

    Recently I came across some great articles on your site.
    The other day, I was discussing (http://iphoneandroid2011.blogspot.in/2013/04/beginners-tutorial-for-object-oriented.html)with my colleagues and they suggested I submit an article of my own. Your site is just perfect for what I have written!
    Would it be ok to submit the article? It is free of charge, of course!

    Let me know what you think
    Contact me at anelieivanova@gmail.com

    Regards
    Anele Ivanova

    ReplyDelete