Taking PHP Seriously
Keith Adams
1.6K106

PHP is a great language, and I have done a lot with it (although my preference for new work these days would be Node)…

However, PHP lends itself to a lot of really poorly written code, and I think that has a lot to do with its rep. Newbies who don’t know better abuse the hell out of the <?php do something ?> syntax, making for an unreadable mish-mash of html, css, js, and php in the same line.

I’ve seen it. The horror…

Some 3rd party WordPress code out there will make your head spin.

Use Here Documents. PHP (and many other languages) has excellent support for it.

Flip your thinking. Don’t use PHP to interrupt the flow of HTML/CSS/JS. Write PHP which includes your HTML/CSS/JS, and which interpolates variables within. It is a LOT cleaner.

I wrote about this a long time ago. How long? April 2003!

Show your support

Clapping shows how much you appreciated Daniel Smith’s story.