View Review Details


Book:   PHP Hacks
Subject:   Big bug in cal2.php script
Date:   2007-05-19 04:10:29
From:   Anonymous Reader
Rating:  StarStarStarStarStar

I really loved this book as I am a php beginner. I'm also glad because I could debug a file :


If you get the scripts at http://examples.oreilly.com/phphks/


Look for cal2.php in cal directory, it was a review made by Alexander Naumann.
The calendar script works well except in one case :
when the first day of month is a sunday !


To debug, find :
# numeric weekday of the first day in
# the current monthz
$day = jddayofweek( $jd ) - 1;


and just add : if ($day<0){$day=6;}


Finally your file will look this way :


# numeric weekday of the first day in
# the current monthz
$day = jddayofweek( $jd ) - 1; if ($day<0){$day=6;}


Enjoy this great calendar !