Attributes vs. Accessors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.

Curious. Which do you prefer and why?

<?php
class Hello {
    public $hi;

    function __construct () {
        $this->hi = 'Well Hello There!';
    }

    function hi () {
        return $this->hi;
    }
}

$hello = new Hello ();

// Access the value this way...
echo $hello->hi;

// or the accessor...
echo $hello->hi();
?>

For publicly-declared variables, do you access the attribute directly or use an accessor?

~Philip

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux