Reputation: 113
I may be asking this question wrong but I'm having trouble finding any specific answers. In most examples of the MySQL PDO I see, it's being used with functions for example:
function getContent() {.....}
So my question is.... is the PDO I see being structured this way for security purposes or is it for other reasons such as cosmetic and or to prevent repetition etc?
Upvotes: 0
Views: 27
Reputation: 9866
Code ran in a function is scoped to that function, so parameters are encapsulated (i.e., not global). Apart from that, there's no real benefits to security. It's the same as executing the code from anywhere else. Most people use methods to organise code for reusability and to avoid repetition more than anything.
Upvotes: 1