Utterly Boring dot com

Cleaning PHP code is Fun

Really. I'm serious. At least in this case, it was fun, because I know now that it's done, my life will be a lot easier.

My work site is powered by PHP. The off-the-shelf script I used to power the home manager is called Free Realty. I'm using an older version of it where the code isn't as clean (and even the new version isn't as clean as it probably could be, but it's fairly plug and play). But the version I have used a TON of echo statements to create its various pages. Now, echo statements are fine if you're processing variables inside those echoes, but there were just large echo statements full of HTML, and it was just annoying to look at, especially so since HomeSite doesn't color code the HTML inside PHP tags -- meaning it's really hard to read. So today I got rid of a bunch of echo tags, did a lot more in-line PHP if/else stuff, replaced the longer echo blocks with short-tag versions of echo in-line with the HTML, reduced the amount of overall if/else statements and the code is a lot cleaner and easier on the eyes. It will make a future project I'm working on a hell of a lot easier, too (as I plan on reusing a lot of this same code).

I'm starting to pretend pretty well that I know what I'm doing with this stuff ;-) Prior to this job, I didn't know a damn thing about PHP, other than knowing a coworker or two were studs at it. But working here was the first real shot I've had at it, and it's a blast. Beats working on the piece of crap ASP server I have upstairs any day of the week.

Posted by Jake on 03/28/04 @ 05:43 PM
Posted in Jake | 6 Comments | Permalink



6 Comments

Jon said on 03/28/04 @ 11:41 PM:
Sounds like a good start, but take it a step further: templates, man, templates.

:)

Jake Ortman said on 03/29/04 @ 09:57 AM:
Step ahead of you :-)

I used template-like includes for every site I do, including this one.

Jon said on 03/29/04 @ 02:03 PM:
Excellent....... :)

Hervard said on 04/23/04 @ 07:59 AM:
It's good when you learn new things like this, and get paid to do it. Sounds like me with a job that I had. I was required to build a database-driven news site, so I taught myself PHP/MySQL and made it. I think I had a whole bunch of echo statements, heh.

Jeff Wilkinson said on 04/19/05 @ 07:33 AM:
since you use homesite, have you gotten any of the extensions for php from my php4hs site?
(www.wilk4.com/asp4hs/php4hs.htm)

Other user wrote 'em, and many are pretty handy. (and free)

Jake said on 04/20/05 @ 11:38 AM:
Jeff: I had not, and will be downloading them. Thanks!

Post a comment












HTML Allowed: a href, b, br, p, strong, em, ul, li, blockquote




Comment Policy: Comments on older entries or comments containing a bunch of links are moderated automatically on this site to help fight comment spam. If you don't see your comment after submitting, it will appear on the site after it has been approved. We also reserve the right to remove your comment for any reason we see fit, but if you keep it remotely on topic, it'll stay. If you want a comment removed, e-mail us, but you'd better have a dang good reason or a truck load of money.

What are you doing down here? Don't you have something better to do? Like Go Back To The Top of the page, or even see who created this site? This site is © 2001 - 2014 by the Utterly Boring folks at UtterlyBoring.com. Steal my content, as I probably did, too, just link to my site or the original site. Batteries not included. One size fits all. Not for off-road use. Not for internal use. Do not taunt Happy Fun Ball.