Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Question is simple and I am asking to see what is the best and easiest way to do it.

As an example, I made a very short logging function that will log data the way I need too. I want to then use this Logger function across my entire project on different sections of the code to log what's going on.

My first thought is to add it to some of the code that is used by everything in the Project. Can I add code to the base PHP Code that exists? I can use functions from PHP anywhere.

Another thought is I would have to have a use statement in every other file that would use it.

As an additional bonus point question Can I make it in a way where I don't have to create an instance of an object to use a single function?

I'm trying to look at this open-minded and find out what options are out there and which would be considered the best and why it is the best.

Thank you

What I have tried:

I have done plenty searches for ways in accomplishing this. Not only how but also looking for why it's better. And then I'm not finding any input on the best way to do this and why it is the best compared to other ways. This question I feel may come off as a simple question to ask but I feel that it's something I never thought to ask a community and may help others in the future.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900