Reserved word include or "use" in PHP?

7

I saw somewhere that the reserved word include in PHP should be used only in procedural programming, and that in object-oriented programming you should opt for the reserved word use .

I did not find anything that would lead me to believe that the substitution is correct. That is, it is the same thing to use include or use to call other parts of the program, that would be like an amount, is not it?

    
asked by anonymous 23.09.2017 / 17:34

1 answer

7

This does not make sense. At least not without an explanation. If you saw it somewhere and did not explain why, ignore, it is possibly this person's taste. If you have an explanation, then if you understand the basics you can assess whether that makes sense or not.

If you do not use include will you load the auxiliary files for that application in that way? It has other similar words , but does essentially the same. There are forms of automatic loading. What can be questionable its use. And if it exists is due to structural failure of language. It has nothing to do with object orientation. Actually little of what people think about OOP really is OOP, and a lot of OO people are unaware even thinking they are using this paradigm.

include loads a source code, use enables the use of a namespace . A namespace is just a way of organizing codes with a surname to facilitate access and disambiguate like names that do different things. The codes are more physical, the namespaces are more logical. You have a question on the subject in another language , but the basic idea is the same.

Even use has to do with non-object oriented modularization.

Every time someone talks about procedural X OOP in PHP has a chance of the person not understanding about OOP and uses it just because it's fashionable, then it thinks that if it does procedural it's doing something wrong, which is far from true, especially in PHP.

    
23.09.2017 / 18:04