Pregunta | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Pregunta

Una pregunta porque cuando heredó una clase de otra por ejemplo... class Carro { private $motor; function Carro { $this->motor=1; } } - class Gandola extends Carro { function Gandola { this-> motor=2; } } $mack= new Gandola; $fortuner=new Carro; echo $mack->motor; No entiendo porque a la hora de imprimir se visualiza el valor del motor de el camión que no no debería noestá heredando el private? Si lo coloco al revés así si funciona echo $fortuner-> motor; echo $mack->motor; Acá se visualiza

16th Nov 2016, 3:38 AM
Cesar Augusto Rondón
Cesar Augusto Rondón - avatar
3 ответов
0
If you want to increase your chances of getting answer I recommend you to write your question in english.
16th Nov 2016, 9:02 AM
Jakub Stasiak
Jakub Stasiak - avatar
0
I do not understand why at the time of printing is displayed the value of the engine of the camera that is not inheriting the private? If I put it backwards so it works
16th Nov 2016, 12:10 PM
Cesar Augusto Rondón
Cesar Augusto Rondón - avatar
0
My question is because when I call the function that gives me the name of the engine that I value, if in fact I should not give me
16th Nov 2016, 12:17 PM
Cesar Augusto Rondón
Cesar Augusto Rondón - avatar