Discussion – Lesson 10 - Static class members in PHP pt. 2 - constants
BackComments
Member
6 messages from 6 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Comments
and why if (Human::validPassword($password))
i look the variable for $password and it is private,,, i though variable
static will do it the 'self:: thank you for answer
'
I can't find any occurrence of , password)
in this lesson, maybe
you just forgot to write $
?
In if (Human::validPassword($password))
, $password
is just a local variable which happens to have the same name as the
$password
property in the class. But these are 2 different
variables, you would have to write $human->password
to access
the property. And as you correctly stated, it wouldn't work since it's
private.
// Contents of the PhpProgrammer.php file
class PhpProgrammer extends Human
{
public $ide;
public function __construct($firstName, $lastName, $age, $password,
$ide)
{
$this->ide = $ide;
parent::__construct($firstName, $lastName, $age, password); // here from the
phpProgrammer
}
I've downloaded the attachment from this article and I can see the
$
there. Can you please recheck it?
Since PHP 8.1 there is support for enum which is imho a great improvment.
See https://php.watch/…ns/8.1/enums
6 messages from 6 displayed.