[Solved] Fatal error: Call to undefined function boolval()

boolval() is a PHP function that was introduced in PHP 5.5. If you try to use it on a server that runs PHP 5.4 and lower, you will get an error like this:

Fatal error: Call to undefined function boolval() in /path/to/file/file.php on line 12

To fix this error, add the following to your WordPress theme’s functions.php

/**
 * Get the boolean value of a variable
 *
 * @param 	mixed 	The scalar value being converted to a boolean.
 * @return 	boolean The boolean value of var.
 * @refer	http://php.net/manual/en/function.boolval.php#114013
 */
if( !function_exists('boolval')) {
  
  function boolval($var){
    return !! $var;
  }
}

Let me know if that helps.

Hello, I am Arun Basil Lal. Thank you for reading!

I am a WordPress product developer and creator of Image Attributes Pro. I am passionate about solving problems and travelling the world.

Divi WordPress Theme - My Review

Divi WordPress Theme
Divi is a WordPress theme that web designers do not want you to know. It comes with a drag-and-drop theme builder. You can build beautiful looking unique websites without touching a line of code. Just choose from one of the many pre-made layouts, or pick elements and arrange them any way you like.

Divi is every WordPress developer's wet dream. Surprise your clients with neat responsive websites and have fun building them.

Divi comes from Elegant Themes. If you enjoy building websites, you *need* an Elegant Themes membership. 87 beautiful themes and 5 plugins for the cost of less than a candy-bar each!


Note: I am an avid user of Divi myself and this is a honest review. I wouldn't recommend something that I do not personally find amazing.

5 Comments.

  1. L. Scott Harrell says:

    Thank you very much! This fix saved me time, money and a lot of aggravation. Cheers!

  2. Rebecca says:

    Thanks mate.
    This worked. Saved me hours of messing with around.

  3. Edgar Castillo Medina says:

    Muchas gracias…funciono perfecto.
    Thanks a lot…a perfect solution!!!
    Regards from Mexico

  4. Joseph says:

    Arun, the code you supplied worked perfectly and I had my site up and running again within seconds. Thank you so much as I appreciate your support. If there is anything I can do to spread the good word and help you, please let me know. Thank you again. -Joseph

Leave a Reply

Your email address will not be published. Required fields are marked *

*