<?php
class Foo
{
protected $protected1 = 'protected1';
public function test1()
{
var_dump($this->protected1);
var_dump($this->protected2);
}
}
class Bar extends Foo
{
protected $protected2 = 'protected2';
public function test2()
{
var_dump($this->protected1);
var_dump($this->protected2);
}
}
(new Bar)->test1();
(new Bar)->test2();
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
string(10) "protected1"
string(10) "protected2"
string(10) "protected1"
string(10) "protected2"