I wish there was a solid rule to follow
I am redoing alot of my code over again. Trying to go OOP… Not actual work, just a pet php project i like to put things I learn into.
I agonize over this. :o :o
[php]define(“PAGE”, “index”);[/php] (this comes from the URL after it is parsed)
I had the above constant referenced all over my code… Procedural
Now am going OOP with classes
So I THINK I wanna use dependency Injection to pass it on to the classes that need it.
It is a public property, (i did want to make it private, but that broke alot of stuff, even using a getter)
But the DEFINE sill works and is easy. and looks soooo very nice. lol
I know that Define is Global space. I can not use a const because it is set at runtime
I keep reading about Encapsulation and that tells me it is bad to use Define(at least how I read it!!! ;D)
Somethings that did not work
so now I am either passing the whole ($obj) to another class or the property ($obj->page)
The way I understand Constants
const - Set at compile time. never…never changes
define - Can vary, set up runtime, like url address
but does it matter? just a matter of prefference?
Anyways, I wish there was a solid rule to follow