$data['captcha'] = create_captcha($code);
How can fix this issue in PHP 8.1 ?
CodePudding user response:
$captcha = create_captcha($code);
$data['captcha_image'] = $captcha['image'];
$data['captcha_word'] = $captcha['word'];
CodePudding user response:
Use the PHP function "is_array()" to confirm the value is an array. If it is an array, capture it and use it as you want.
// Default value
$data['captcha_image'] = '';
$data['captcha_word'] = '';
$captcha = create_captcha($code);
if (is_array($captcha)) {
$data['captcha_image'] = $captcha['image'];
$data['captcha_word'] = $captcha['word'];
}