Captcha error word_length |
I am testing Captcha and my code is like this:
Code: $this->load->helper('captcha'); This works OK but if the 'word' line is commented out I get a php error Undefined variable: word_length although the User Guide says 'If a word is not supplied, the function will generate a random ASCII string.' Is this a bug or have I made a mistake in the coding?
Don't comment out the 'word' string inside the array. You can put the string with no value, or NULL value. Try something like this:
$vals = [ 'word' => NULL, 'img_path' => CAPTCHA_IMG_PATH, 'img_url' => site_url('publico/imagens/captcha'), 'img_width' => '150', 'img_height' => '30', 'font_path' => FONTS_PATH . 'ArialMTRegular.ttf', 'expiration' => $this->config->item('captcha_expiration', 'captcha'), 'word_length' => 6, 'font_size' => 14, 'img_id' => 'captcha-image', 'img_alt' => 'failed-to-captcha-image', 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'colors' => [ 'background' => array(255, 255, 255), 'border' => array(255, 255, 255), 'text' => array(255, 120, 120), 'grid' => array(255, 182, 182) ] ]; $cap = create_captcha($vals); echo $cap['image']; |
Welcome Guest, Not a member yet? Register Sign In |