public function strImage($str) { // 建立一幅 100X30 的图像 $im = imagecreate(55, 30); // 白色背景和蓝色文本 D6BB86 //$bg = imagecolorallocate($im, 0xd6, 0xbb, 0x86); $bg = imagecolorallocate($im, 0xff, 0xff, 0xff); $textcolor = imagecolorallocate($im, 0, 0, 0); // 把字符串写在图像左上角 imagestring($im, 5, 5, 5, $str, $textcolor); // 输出图像 mPHP::header('Content-Type', 'image/png'); imagepng($im); }
public function cache($file, $cacheTime) { $this->is_cache = true; $time = $_SERVER['REQUEST_TIME']; $createTime = file_exists($file) ? filemtime($file) : 0; if ($createTime + $cacheTime >= $time && !mPHP::$debug) { $createTime = date("D, d M Y H:i:s", $createTime); mPHP::header('Cache-Control', 'max-age=0'); mPHP::header('Last-Modified', $createTime); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $createTime) { mPHP::status(304); } else { include $file; } mPHP::_exit(); return true; } return false; }