Get up to 80 % extra points for free! More info:

Discussion – Lesson 10 - Static class members in PHP pt. 2 - constants

Back

 

Comments
Avatar
Justin Jake Telo:2/12/2018 0:14

parent::__con­struct($firstNa­me, $lastName, $age, password);

why is the "password" have no $ sign? please enlighten me thank you very much

 
Reply
2/12/2018 0:14
Avatar
Justin Jake Telo:2/12/2018 0:16

and why if (Human::valid­Password($pas­sword))

i look the variable for $password and it is private,,, i though variable static will do it the 'self:: thank you for answer
'

 
Reply
2/12/2018 0:16
Avatar
Replies to Justin Jake Telo
David Capka Hartinger:2/12/2018 5:41

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.

Edited 2/12/2018 5:47
Reply
2/12/2018 5:41
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Replies to David Capka Hartinger
Justin Jake Telo:2/13/2018 5:52

// Contents of the PhpProgrammer.php file
class PhpProgrammer extends Human
{

public $ide;

public function __construct($fir­stName, $lastName, $age, $password, $ide)
{
$this->ide = $ide;
parent::__con­struct($firstNa­me, $lastName, $age, password); // here from the phpProgrammer
}

 
Reply
2/13/2018 5:52
Avatar
Replies to Justin Jake Telo
David Capka Hartinger:2/26/2018 10:57

I've downloaded the attachment from this article and I can see the $ there. Can you please recheck it?

Edited 2/26/2018 13:38
Reply
2/26/2018 10:57
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Inactive member:4/27/2022 13:20

Since PHP 8.1 there is support for enum which is imho a great improvment.
See https://php.watch/…ns/8.1/enums

Reply
4/27/2022 13:20
Inactive user account.
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

6 messages from 6 displayed.