src/Captcha/Captcha.php
public static function init( $blocks = 2, $block_min_length = 4, $block_max_length = 7 )
	{
		if( !is_numeric( $blocks ) || !is_numeric( $block_min_length ) || !is_numeric( $block_max_length ) )
			throw new CaptchaException( __METHOD__ . ' arguments must be numeric values' );

		if( $blocks < 1 || $blocks > 5 )
			throw new CaptchaException( '__construct($blocks, , ) $blocks must be +ve integer and less than or equal 5.' );

		if( $block_min_length < 1 || $block_min_length > 20 )
			throw new CaptchaException( '__construct( , $block_min_length, ) $block_min_length must be +ve integer' );
		
		if( $block_max_length < $block_min_length || $block_max_length > 100 )
			throw new CaptchaException( '__construct( , , $block_max_length ) $block_max_length must be +ve integer and greater than or equal to min_length and less than 100' );

		#	Generate Captcha Code


		$code = '';

		$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		
		for( $i = 1; $i <= $blocks ; $i++)
		{
			# generate block #i
			
			$block_length = rand( $block_min_length, $block_max_length );
			
			# get block, from 0 to length-1 to get exact block_length
			$code .= substr(str_shuffle(str_repeat($pool, 5)), 0, $block_length-1 );

			# Add Space if it wasn't the last block
			$code .= ( $i >= $blocks ) ?: ' ';
		
		}
		
		# Save Captcha Code To Session	
		Session::put( 'captcha', $code );
	}
public static function init( $blocks = 2, $block_min_length = 4, $block_max_length = 7 )
	{
		if( !is_numeric( $blocks ) || !is_numeric( $block_min_length ) || !is_numeric( $block_max_length ) )
			throw new CaptchaException( __METHOD__ . ' arguments must be numeric values' );

		if( $blocks < 1 || $blocks > 5 )
			throw new CaptchaException( '__construct($blocks, , ) $blocks must be +ve integer and less than or equal 5.' );

		if( $block_min_length < 1 || $block_min_length > 20 )
			throw new CaptchaException( '__construct( , $block_min_length, ) $block_min_length must be +ve integer' );
		
		if( $block_max_length < $block_min_length || $block_max_length > 100 )
			throw new CaptchaException( '__construct( , , $block_max_length ) $block_max_length must be +ve integer and greater than or equal to min_length and less than 100' );

		#	Generate Captcha Code


		$code = '';

		$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		
		for( $i = 1; $i <= $blocks ; $i++)
		{
			# generate block #i
			
			$block_length = rand( $block_min_length, $block_max_length );
			
			# get block, from 0 to length-1 to get exact block_length
			$code .= substr(str_shuffle(str_repeat($pool, 5)), 0, $block_length-1 );

			# Add Space if it wasn't the last block
			$code .= ( $i >= $blocks ) ?: ' ';
		
		}
		
		# Save Captcha Code To Session	
		Session::put( 'captcha', $code );
	}
public static function init ( $ blocks = 2 , $ block_min_length = 4 , $ block_max_length = 7 ) { if ( ! is_numeric ( $ blocks ) || ! is_numeric ( $ block_min_length ) || ! is_numeric ( $ block_max_length ) ) throw new CaptchaException ( __METHOD__ . ' arguments must be numeric values' ) ; if ( $ blocks < 1 || $ blocks > 5 ) throw new CaptchaException ( '__construct($blocks, , ) $blocks must be +ve integer and less than or equal 5.' ) ; if ( $ block_min_length < 1 || $ block_min_length > 20 ) throw new CaptchaException ( '__construct( , $block_min_length, ) $block_min_length must be +ve integer' ) ; if ( $ block_max_length < $ block_min_length || $ block_max_length > 100 ) throw new CaptchaException ( '__construct( , , $block_max_length ) $block_max_length must be +ve integer and greater than or equal to min_length and less than 100' ) ; #	Generate Captcha Code $ code = '' ; $ pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; for ( $ i = 1 ; $ i <= $ blocks ; $ i ++ ) { # generate block #i $ block_length = rand ( $ block_min_length , $ block_max_length ) ; # get block, from 0 to length-1 to get exact block_length $ code .= substr ( str_shuffle ( str_repeat ( $ pool , 5 ) ) , 0 , $ block_length - 1 ) ; # Add Space if it wasn't the last block $ code .= ( $ i >= $ blocks ) ? : ' ' ; } # Save Captcha Code To Session	 Session :: put ( 'captcha' , $ code ) ; }
This Method Will Generate a Capatcha Code and Store it in Session
This Method Will Generate a Capatcha Code and Store it in Session