How to remove the warning not to use VAR in Netbeans?

Asked

Viewed 97 times

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

inserir a descrição da imagem aqui

How do I remove this?

  • 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?!

  • But from php5 you no longer need to use the var $nomedavariavel just use the $nomedavariavel

  • 3

    From what I understand of answer you accepted, requires an access modifier, says nothing about not using nothingness before the attribute name.

  • 1

    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.

  • I had it wrong.

  • Be careful variable and attribute/property are different things, if you notice no comment or answer cited variable.

  • Thanks rray, I’m getting a little confused in this entrance in POO, but I’m studying.

  • 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!

Show 3 more comments

1 answer

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;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.