|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-04 17:03 UTC] uramihsayibok at gmail dot com
[2010-11-04 19:07 UTC] sjors dot vanleeuwen at itsxtreme dot com
[2010-11-05 04:37 UTC] aharvey@php.net
-Status: Open
+Status: Bogus
[2010-11-05 04:37 UTC] aharvey@php.net
[2015-03-20 15:01 UTC] levim@php.net
-Status: Not a bug
+Status: Duplicate
[2015-03-20 15:01 UTC] levim@php.net
[2015-03-20 15:02 UTC] levim@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 00:00:02 2025 UTC |
Description: ------------ It would be very usefull to have getters in a way like c#. Example: Class Test { private $_a; private $_b; public function get a() { return $this->_a; } } this way the private $_b isn't available to the outside world which is the case with out of the box __get. It also (in my opinion) gives your code a much cleaner look and you can do special things if needed in your functions too. in the __get function you'll have to make if statements or other checks to get the same result. You can also just use: Example: Class Test { private $_a; private $_b; public function a() { return $this->_a; } } but then you would have to use: $test->a() instead of $test->a which gives a wrong assumption that you are calling a function which you are not, you are calling a property of your object.