Linked by John Collins on Wed 21st Apr 2004 06:42 UTC
The purpose of this article is to give a novice programmer the basic idea of what OOP is, as implemented using PHP. Readers should have a basic knowledge of programming ie what variables are, variable types, basic methods of writing comments, and how to enter code into a text editor.
Permalink for comment
To read all comments associated with this story, please click here.
The whole "getter" and "setter" thing is not necessarily the only way to go. For example, C# has the concept of Accessors, which makes it "seem" like you are accessing properties directly, but in fact every request of a property gets passed through the method(s) of your choice anyway.
Think of it like having triggers and constraints in an SQL database. Even though the query is simply getting or setting a database value, the system intercepts that query and performs additional or substitutional logic.
Fortunately, PHP allows for this with the Overload extension (http://php.net/overload), which is available in PHP4 and PHP5.
The whole "getter" and "setter" thing is not necessarily the only way to go. For example, C# has the concept of Accessors, which makes it "seem" like you are accessing properties directly, but in fact every request of a property gets passed through the method(s) of your choice anyway.
Think of it like having triggers and constraints in an SQL database. Even though the query is simply getting or setting a database value, the system intercepts that query and performs additional or substitutional logic.
Fortunately, PHP allows for this with the Overload extension (http://php.net/overload), which is available in PHP4 and PHP5.