Re: cal_days_in_month() missing, how can I tell if it exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 1 Feb 2005 18:57:12 -0600, James Kaufman
<jmk@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Tue, Feb 01, 2005 at 08:47:29PM +0000, Ben Edwards wrote:
> > I have been implementing a system on a different ISP than I normally use
> > and have got:-
> >
> > Fatal error: Call to undefined function: cal_days_in_month()
> > in /home/hosted/www.menublackboard.com/public_html/dev/classes/validator.class.php
> > on line 134
> >
> > I found a reference to this an the web and it seems PHP is not compiled
> > with calender support.
> >
> > "recompile php with the "--enable-calendar" option."
> >
> > Cant see being able to get the to re-compile PHP so I guess I am going
> > to have to disable the feature.  I seem to remember a while ago seeing a
> > function to test weather a function exists in PHP.  That way I can have
> > the relevant validation skipped if the function is missing (I will tell
> > the client if they get decent hosting it will start working).
> >
> > So something like
> >
> >   function_exists(  cal_days_in_month() )
> >
> > Anyone know what the function is called.
> >
> > Ben
> >
> 
> I do this:
> 
> if (!extension_loaded('calendar'))
> {
>     /*
>      * cal_days_in_month($month, $year)
>      * Returns the number of days in a given month and year,
>      * taking into account leap years.
>      *
>      * $month: numeric month (integers 1-12)
>      * $year: numeric year (any integer)
>      *
>      * Prec: $month is an integer between 1 and 12, inclusive
>      *       $year is an integer.
>      * Post: none
>      */
>     function cal_days_in_month($month, $year)
>     {
>         return $month == 2 ? $year % 4 ? 28 : 29 : ($month % 7 % 2 ? 31 : 30);
>     }
> }

thanks, I was using

$days_in_month = cal_days_in_month( CAL_GREGORIAN, $month, $year );

Is the first parameter optionel.  If it is I guess PHP must have
overloaded internal functions.

Ben

> --
> Jim Kaufman
> Linux Evangelist
> public key 0x6D802619, CISSP# 65668
> http://www.linuxforbusiness.net
> ---
> The shortest distance between two points is through Hell.
>                 --Brian Clark
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux