RE: [PHP] OOP .. I just don't get it.
| From: | Demitrious S. Kelly | Date: | Tue, 05 Mar 2002 20:30:34 +0000 |
| Subject: | RE: [PHP] OOP .. I just don't get it. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-87339@lists.php.net to get a copy of this message | ||
I've often wondered the same thing... which is why I've never moved to
OOP
So I'm patiently waiting for a reply to this message as well :)
-----Original Message-----
From: mojo jojo [mailto:thomasp@chc.quik.co.nz]
Sent: Tuesday, March 05, 2002 12:22 PM
To: php-general@lists.php.net
Subject: [PHP] OOP .. I just don't get it.
Hi
I've been using php for a while now but I have not got my head around
OOP
(classes).
Why bother using them? I've read thru a few tutorials on using classes
and
the examples given are quite simple. This is probably the problem - I
just
can't see the benefit of using this style of programming.
Here is what I'm getting at.
------------USING A CLASS-----------------
class Table {
var $rows;
var $columns;
function MakeTable() {
draw a table with $this->columns as the number of columns
and $this->rows as the number of rows
}
}
$mytable = new Table;
$mytable->rows = 5;
$mytable->columns = 10;
$mytable->MakeTable();
---------------USING A NORMAL FUNCTION-----
function MakeTable($rows,$columns) {
make a table with $rows as the number of rows
and $columns as the number of columns
}
$rows = 5;
$columns = 10;
MakeTable($rows,$columns);
-----------------------------------------------------------
Using a class doesn't appear to give me any benefits - in fact the code
is
longer.
I know that you can spawn more instances of the same class which sounds
useful, however I can also run my function as many times as I like using
different variables.
What am I missing here?
Thanks
Mojo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php