There’s Always A Better Way
I’m a firm believer in the statement, “There’s always a better way.” When I started learning PHP, I assumed that what I was reading was hardcore `gospel` truth. What I realized later as I was trying to maintain my code was, there is a better way to do this. I was really irritated when my epiphany hit me. Irritated that I didn’t think of it sooner, but I was the novice and I chalked it up to learning, then I got really irritated at the authors of the PHP information I was reading because they never provided a clue, “there’s an easier way to do this…”
For PHP Beginners
When I was first learning how to use PHP, I was looking for all the knowledge I could get. I bought book, read tutorials online, what ever I could find, people to talk to. I quickly realized that no two people had the same approach to teaching beginners and, they often made reference to not providing information that they thought to be useful but possibly confusing.
WHAT! Are you kidding me? So while the author spouts off about how this function operates just like it’s C counter part (which I know nothing about), they won’t provide me with knowledge that may be useful to the language I’m actually learning?
So if you’re just starting to learning PHP keep these helpful tips in mind.
A Different Approach to Parsing HTML as PHP
On occasion it’s necessary for me to process HTML files as PHP. Reasons vary, but usually it’s because the clients web site was originally set up as static HTML and we need to process dynamic content, but due to SEO reasons, we can’t change the file extensions.
Generally a simple .htaccess file can handle this process for you and make simple work of the informing the server to parse HTML as PHP. Some people complain of the load that this can put on the server, but I think this argument is unfounded.
What should be a simple solution, can often turn into an enormous problem. Things being what they are, we ran into a server where our simple two line .htaccess file failed to do the job. All manner of adjustments made between the .htaccess file, changes made by our server admin to the Apache httpd.conf file, all failed.
So in the event that these lines don’t work (while all of the Google results say that they do…)
