All Questions
5 questions
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;
...
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;...
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 ...
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;
}...
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 ...