If I made my PHP code which would connect me to my MySQL database in a separate PHP file and made a require on the necessary pages of my website would the DB Connent PHP file be an Object Orentated item ?
相关问题
- Views base64 encoded blob in HTML with PHP
- how to define constructor for Python's new Nam
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Keeping track of variable instances
Oliver, Check out this link about object oriented PHP. It will give you a basic intro and then you can determine if indeed your code is object oriented.
That depends on the code in the seperate file. If it's within a class that you call, rather than just a set of functions, then yes. If not, no.
OOP is a concept. So if you include a file via the require command and this included file utilizes OOP then your script uses the concept of OOP. If not then your mainscript doesn't include it, too.
You need to know that basically require only puts the text from the required file into the executing .php file.
So it doesn't make your code any more OOP by requiring another file, it just makes it more structured and maybe more maintainable in the future, but not OOP.
OOP would mean that you have created some sort of object that you call from now on to execute commands against. You can read more on OOP in Wikipedia
I strongly suggest you read the book "Code Complete" if you are just beginning with programming and just keep on experimenting. The road to OOP programming usually leads through lots of bad procedural programming (that's what you are most likely doing right now).
Of course. You could also use MySQLi, which is object oriented as well.