<html>
<body>
class MyClass {
protected $number = 0;
}
class AnotherClass {
public function add1() {
$this->number++;
}
public function getNumber() {
return $this->number;
}
}
$obj = new AnotherClass();
$obj->add1();
echo "The number is " . $obj->getNumber();
</body>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_keyword_protected by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:22:56 GMT -->
</html>