Ian Landsman is Starting From Scratch, October 16, 2004:

Development Tips

If you're in the market for a powerful and user friendly Help Desk solution, please take a look at my company's flagship product HelpSpot.
Alex King posted a nice tip I use alot about imploding an array to make a separated string without having to worry about having an extra separator left on the end.

One thing I've noticed alot in PHP is people not initializing their variables. I'm not sure why this is but it's really important to do. Coming from a CF background before PHP I grew very used to doing this with the extremely easy <cfparam> tag. My replacement for this in PHP is to put the following code at the top of my scripts for each variable, especially ones coming from an external source:

$page = isset($_GET['page']) ? $_GET['page'] : 'home';

So if the variable page is set then place it in the local $page variable otherwise set it to some default. It's also possible to expand on this and do some other types of data checking right here, for instance:


$id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? $_GET['id'] : 0;

Here we're checking to see both if $_GET['id'] is set and if it is numeric. If it isn't we set to the default of zero.
Created on 10.16.2004 12:10 pm · Comments (2)


Discussion

Created by on 10.16.2004 1:10 pm

-----

Created by on 10.16.2004 1:10 pm

 

Leave a Comment

Commenting is not available in this weblog entry.


> RSS 2.0
> Blog Archives (complete list)
> HelpSpot Mailing List

Copyright © by Ian Landsman

Design by Jakob Nielsen