Archive for August, 2006
Tip of the Week: ‘==’ vs ‘===’
Wednesday, August 9th, 2006So, if you are checking if a variable is set to true or false, i suggest doing it using ‘===’ instead of ‘==’ this is because in php the value of false is 0 and true is 1, when you use the === it checks the variable type as well, where as ‘==’ only checks if they are equal.
Don’t Reinvent the Wheel
Monday, August 7th, 2006Well, as with most things on the web, you can usually use google to find and get code, so that you don’t have to do stuff from scratch, for web developers there is a nice set of code for User Interface Stuff and One about Design Patterns available from Yahoo.
I can’t wait to play with these.
Gotcha: file_exists vs. is_file
Friday, August 4th, 2006Sometimes i miss the fine print, today i made minor opps. I was using file_exists() to check for a file, it was returning true even when the file wasn’t there. After awhile i realised that i was using the wrong function to check for the file.
file_exists will return true for file and directories, you should rather use is_file() to check for files.
if( file_exists(UPLOAD_DIR.$_FILES['file_1']['tmp_name']) ){
//WRONG WAY!! THIS WILL STILL RETURN TRUE IF FILE IS NOT THERE
}
if( is_file(UPLOAD_DIR.$_FILES['file_1']['tmp_name']) ){
//CORRECT WAY!!
}