<?php /** * Created by PhpStorm. * User: yiban * Date: 2015/7/20 * Time: 10:13 */ require './CaptchaFactory.php'; $captchafactory = new CaptchaFactory(); $captchafactory->setCaptchaAttrs(170, 50, './tupian.ttf', 16, 8); session_start(); $img = $captchafactory->generateCaptcha(); $_SESSION['captcha'] = $captchafactory->getCaptcha(); header('Content-type:image/png'); imagepng($img); imagedestroy($img);