1
Right here in the OS, I saw that I no longer need to use VAR, when declaring a variable in PHP, this was only until PHP4. Netbeans keeps giving error, if I don’t use, and use only the variable
How do I remove this?
1
Right here in the OS, I saw that I no longer need to use VAR, when declaring a variable in PHP, this was only until PHP4. Netbeans keeps giving error, if I don’t use, and use only the variable
How do I remove this?
1
To declare an attribute within a class in PHP, you declare the visibility, then the attribute.
Right
<?php
Class MinhaClasse{
public $atributo;
}
Wrong
Class MinhaClasse{
$atributo;
}
Have in case that declare then if it is a public variable, private or locked ne?
Within class yes
Thank you, Paulo!
Browser other questions tagged php oop netbeans
You are not signed in. Login or sign up in order to post.
I don’t know much about PHP, but I think you’re declaring class attributes, not variables. I don’t know if this makes a difference in language. By error, it seems that an access modifier is required before
$modelo;
, nay?!– Renan Gomes
But from php5 you no longer need to use the var $nomedavariavel just use the $nomedavariavel
– Lucas de Carvalho
From what I understand of answer you accepted, requires an access modifier, says nothing about not using nothingness before the attribute name.
– Renan Gomes
That’s what Renan said, to remove the warning has two ways, use an IDE that does not warn :), which do not recommend, or fix the problem in the code.
– Maniero
I had it wrong.
– Lucas de Carvalho
Be careful variable and attribute/property are different things, if you notice no comment or answer cited variable.
– rray
Thanks rray, I’m getting a little confused in this entrance in POO, but I’m studying.
– Lucas de Carvalho
Just remember that learning Object-Oriented syntax doesn’t make you object-oriented (and there’s nothing wrong with that). If you program in structured paradigm, I recommend that you stay a while still programming in this paradigm, even using object-oriented syntax (for community reasons, not possible to explain here). The use cases where you will take advantage of the object-oriented paradigm will appear naturally. Don’t fall for the "real programmer does this..." or "that..." talk. Good luck to you!
– Paulo Sérgio Duff