What is the best way?
- include the script
- write the script as function in for example functions.php, include the functions.php and call function
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I still don’t understand the differences of your approaches.
But if you have a lot code in this file, indeed, the best way would be to write your code as functions (if you do not already have that) and create several files that contain those.
You should try to categorize your functions and create an own file for each category. Then you have more control over which functions you include and you don’t have to include all of them, you just include those files you need the functions from.
For example you can create a file
database_util.phpthat contain database related functions, etc.In the long run, you should learn about Object Oriented Programming, but don’t misuse classes / objects as container of functions. This is not the purpose of OOP and won’t help you much.