DJ_AM_Juicebox
asked on
PHP + properties
Hi,
If I understand properties (PHP 5+) correctly, your class has one __set() and one __get() method, like:
function __get($propName) {
if ($propName == 'size') {
...
}
else if ($propName == 'height') {
...
}
}
function __set($propName, $value) {
if ($propName == 'size') {
...
}
else if ($propName == 'height') {
...
}
}
How does that scale once you start getting a lot of properties in your class? It seems similar to doing a linear search in an array.
Thanks
If I understand properties (PHP 5+) correctly, your class has one __set() and one __get() method, like:
function __get($propName) {
if ($propName == 'size') {
...
}
else if ($propName == 'height') {
...
}
}
function __set($propName, $value) {
if ($propName == 'size') {
...
}
else if ($propName == 'height') {
...
}
}
How does that scale once you start getting a lot of properties in your class? It seems similar to doing a linear search in an array.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The above is obviously a trivial example, but it's great because you can handle new properties without modifying any code, and you can change the implementation or add error checking without changing the API you expose.
ASKER
I see, thanks.