Copy Code code as follows:
Class Foo
{
Private $name = ' hdj ';
Public Function GetName () {
return $this->name;
}
}
Class Bar extends Foo
{
Public $name = ' Deeka ';
}
$bar = new Bar;
Var_dump ($bar->name);
Var_dump ($bar->getname ());
Access control
Access control on a property or method is implemented by adding the keyword public, protected, or private earlier. A class member defined by public can be accessed anywhere; A class member defined by protected can be accessed by subclasses and the parent class of the class in which it resides (of course, the class in which the member is also accessible), whereas a class member defined by private can only be accessed by its class.
Copy Code code as follows:
<?php
$a = 3;
$b = 6;
if ($a = 5 | | $b = 7) {
echo $b. ' <br/> ';
$a + +;
$b + +;
}
Var_dump ($a, $b);
Echo ' <br/> $a = (5 | | $b = 7) ';
echo ' $a = 3;
$b = 6;
$c = 1;
if ($a = 5 | | $b = 7 && $c = 10) {
$a + +;
$b + +;
}
Var_dump ($a, $b, $c);
Echo ' <br/> && | | High ';
echo ' $a = 3;
$b = 6;
$c = 1;
if ($a = 0 | | $b = 7 && $c = 10) {
$a + +;
$b + +;
}
Var_dump ($a, $b, $c);
echo ' <br/> ';
echo '
Class Foo {
Private $name = ' hdj ';
Public Function GetName () {
return $this->name;
}
}
Class Bar extends Foo {
Public $name = ' Deeka ';
}
$bar = new Bar;
Var_dump ($bar->name);
Var_dump ($bar->getname ());