The thing about PHP classes is that there are not many rules.  It is
usually suggested, as a matter of good practice to use get and set
functions for your variables in classes in any language.  A lot of
people my think this is a bunch of extra work, but let's say you are
keeping track of customers, and you are storing their phone number.  If
you write get/set functions for that variable, if later on you decide
that you really need to be validating the phone numbers format, or
getting a particular format out of the class you can easily add that
code right in the get/set function and then that process only has to
happen in one place, keeping your code nice and clean.

greg

-----Original Message-----
From: Gerard Samuel [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 03, 2002 6:45 AM
To: php-gen
Subject: [PHP] Info into Class


Are there any rules as to how information from outside a class can be 
moved into it.
What Ive been doing so far is
1.  Through the constructor
2.  defining a constant
3.  Create a method whose sole purpose is to move data from the outside 
into the class.
     i.e.
<?php
class foo ()
{
......
    function outside_data($bar)
    {
        $this->bar = $bar;
    }
......
}

// class constructor here
.......
$class->outside_data($php);

?>

-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to