Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
2 answers
519 views

PHP OOP private protected

I have the following code: Class definition: <?php class Person{ var $name; public $height; protected $socialInsurance = "yes"; private $pinnNumber = 12345; ...
Michal Vlasák's user avatar
0 votes
2 answers
481 views

PHP variable scope within classes

I am trying to make a class that simply holds and retrieves simple string variables. Here is what i have in the User.php file (the class) class User { //private variables private $u_s; private $p_w;...
Jake Psimos's user avatar
19 votes
4 answers
43k views

PHP - Private class variables giving error: undefined variable

I am getting the error "Undefined variable: interval in C:\wamp\www\DGC\classes\DateFilter.php" Here is my code for the DateFilter class: class DateFilter extends Filter { //@param daysOld: how ...
CHawk's user avatar
  • 1,356
7 votes
5 answers
4k views

The advantage / disadvantage of private variables?

I'm used to make pretty much all of my class variables private and create "wrapper" functions that get / set them: class Something{ private $var; function getVar(){ $return $this->var; }...
Alex's user avatar
  • 66.3k
11 votes
3 answers
16k views

Which is better in PHP, Static Variable or Private Variable? [closed]

I noticed two ways in PHP to do the same thing. Can you tell me which way is a better programming practice? In the first example, I use a private variable on the class. On the second example, I use a ...
Volomike's user avatar
  • 24.9k