简体   繁体   中英

PHP 8.1.6, XAMPP -> Fatal error: Uncaught Error: Call to undefined function grapheme_strlen()

PHP 8.1.6 does not find grapheme_strlen() . Any ideas why this happens?

Full error:

Fatal error: Uncaught Error: Call to undefined function grapheme_strlen() in C:\xampp\htdocs\api\v5\inc\classes\Validation.inc.php:90 Stack trace: #0 C:\xampp\htdocs\api\v5\tests\validation.php(14): Validation::fullname('ann') #1 {main} thrown in C:\xampp\htdocs\api\v5\inc\classes\Validation.inc.php on line 90

The function:

    /**
     * Checks if a fullname is valid
     *
     * @param string $fullname
     * @return FullnameValidation
     */
    static function fullname(string $fullname): FullnameValidation
    {
        $min_length = 3;
        $max_length = 30;

        if (grapheme_strlen($fullname) >= $min_length) {
            if (grapheme_strlen($fullname) <= $max_length) {
                return FullnameValidation::ok;
            } else {
                return FullnameValidation::too_long;
            }
        } else {
            return FullnameValidation::too_short;
        }
    }

Google gives me exactly zero results. Seems like i'm the only person who ever had this issue.

you need to install the intl pecl extension. i am not a XAMPP person. but if you ran:

php -m

you need to see the intl module to resolve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM