Home > Software engineering >  Fatal error: Uncaught Error: Call to undefined function cal_info()
Fatal error: Uncaught Error: Call to undefined function cal_info()

Time:09-24

for some reason my php application(PHP 7.2.34 (cli)) is crashing in this error. I use cal_info function right here:

private function month($month, $abbrev = true)
    {
        $infos = cal_info( CAL_GREGORIAN );

        if($abbrev)
            return $infos['abbrevmonths'][intval($month)];
        else
            return $infos['months'][intval($month)];
    }

and return this error: Fatal error: Uncaught Error: Call to undefined function cal_info() can you guys help me?

CodePudding user response:

You need to compile your php-installation with --enable-calendar

You can read more about it and how to install it in the php documentation.

Check your php-installation with by running php -i and search for Configure Command. It should contain --enable-calendar if you want to use the cal_info() function. Instead of running php -i you can also write a short php-script and call phpinfo().

CodePudding user response:

If you use a Dockerfile based on php:7.1, you can install the calendar extension by this way:

RUN docker-php-ext-install calendar && docker-php-ext-configure calendar
  •  Tags:  
  • php
  • Related