Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP OOP - Access Modifiers

<?php
class Fruit {
  public $name;
  protected $color;
  private $weight;
}

$mango = new Fruit();
$mango->name = 'Mango'; // OK
$mango->color = 'Yellow'; // ERROR
$mango->weight = '300'; // ERROR
?>
 
PREVIOUS NEXT
Tagged: #PHP #OOP #Access #Modifiers
ADD COMMENT
Topic
Name
2+9 =