mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Best practice property alignment, and group similar property visibilities
This commit is contained in:
parent
f7e00b1437
commit
6ff39aa318
@ -373,12 +373,13 @@ echo $function_name(1, 2); // => 3
|
||||
// Classes are defined with the class keyword
|
||||
|
||||
class MyClass {
|
||||
const MY_CONST = 'value'; // A constant
|
||||
static $staticVar = 'static';
|
||||
public $property = 'public'; // Properties must declare their visibility
|
||||
private $privprop = 'private'; // Accessible within the class only
|
||||
protected $protprop = 'protected'; // Accessible within the class and subclasses
|
||||
const MY_CONST = 'value'; // A constant
|
||||
static $staticVar = 'static';
|
||||
// Properties must declare their visibility
|
||||
public $property = 'public';
|
||||
public $instanceProp;
|
||||
private $privprop = 'private'; // Accessible within the class only
|
||||
protected $protprop = 'protected'; // Accessible within the class and subclasses
|
||||
|
||||
// Create a constructor with __construct
|
||||
public function __construct($instanceProp){
|
||||
|
Loading…
Reference in New Issue
Block a user