initialize([ 'width' => 150, 'height' => 50, 'line' => true, 'curve' => false, 'noise' => 1, // 可选:指定字体路径 // 'fonts' => [__DIR__ . '/../resources/fonts/arial.ttf'] ]); $captch->create(); $_SESSION['captch'] = $captch->getText(); // 设置响应类型为图片 header('Content-Type: image/jpeg'); $captch->output(); exit; } }