SESSION
session赋值
session('name','value');
session取值
$value = session('name');
session删除
session('name',null); // 删除name
session判断是否已经设置
session('?name');
验证码
function YZM() { $config = array( 'fontSize' =>50, // 验证码字体大小 'length'=>3, // 验证码位数 //'useImgBg'=>true,//验证码背景图片 'useZh'=> true,//中文验证码 'fontttf'=>'STLITI.ttf',//验证码字体 'zhSet'=>"淄博汉企",//设置验证码的字符 ); //默认情况下,验证码的字体是随机使用 ThinkPHP/Library/Think/Verify/ttfs/目录下面的字体文件,我们可以指定验证码的字体 $v=new ThinkVerify($config); $v->entry(); } function XianShi() { if(empty($_POST)) { $this->display(); } else { $yzm=$_POST["yzm"]; $verify=new ThinkVerify(); var_dump($verify->check($yzm)); } }
xianshi.html
<load href="__PUBLIC__/Js/jquery-1.11.2.min.js"/> </head> <body> <form action="__ACTION__" method="post"> <img id="y" style="300; height:100px;" src="__CONTROLLER__/YZM" /> <br /> <input type="text" name="yzm" /> <input type="submit" value="提交" /> </form> </body> <script type="text/javascript"> $(document).ready(function(e) { $("#y").click(function(){ var sj=Math.random(); $(this).attr("src","__CONTROLLER__/YZM/c"+sj+""); }) }); </script>
文件上传
function WenJian() { if(empty($_FILES)) { $this->display(); } else { $upload = new ThinkUpload();// 实例化上传类 $upload->maxSize=1024000;// 设置附件上传大小 $upload->exts=array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 $upload->rootPath="./Public/";//文件上传保存的根路径 $upload->savePath="Uploads/"; // 设置附件上传目录 $upload->saveName = 'time';// 采用时间戳命名 $info=$upload->upload(); var_dump($info); } }
wenjian.html
<form action="__ACTION__" method="post" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="submit" value="上传" /> </form>