PHP: Underscores for Private
Jeffrey Way released a new Laracasts Snippet, and in it, he mentioned a tweet from me:
When I started with PHP it was beautiful in its simplicity. I still love finding old projects that use underscores to designate protected or private. #nostalgic pic.twitter.com/1cWgNd7hdj
— Eric L. Barnes (@ericlbarnes) April 19, 2019
In the podcast, he talked about how PHP felt more “libertarian” in the early days. The underscore represented that this should be protected or private and even though this is a recommendation from the creator of the code, you are an adult, and if you want to do something with it, then you accept the risk.
The language and community have since switched the stance, and now everyone wants to restrict it with the feeling that if it’s code you are writing, then you know best how it should be used.
I’m not sure one way is better than the other, but as I mentioned in the tweet, I miss the old days.