in PHP4 there is no public,private,etc. So I am wondering if there is some sort of work-around so that I can make a class's property private and only accessible via getter/setter
Thanks!!
in PHP4 there is no public,private,etc. So I am wondering if there is some sort of work-around so that I can make a class's property private and only accessible via getter/setter
Thanks!!
You can't. Since the property is itself public, anyone can access it without getter / setter preventing you from actually performing any checks in between.
You could approach this with a distinct syntax that clearly discourages the usage of such properties. You could borrow the python syntax of starting the method name with an underscore to define it as private.
This doesn't block anyone from using it, of course, but its usage will be discouraged.
you can still write getters and setters for that variable, but there is no way to make a function private in PHP 4.