为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
PHP进阶篇_学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

PHP进阶篇

Jason PHP开发工程师
难度初级
时长 9小时28分
  • try{ throw new Exception("found error"); }catch(Exception $e){ $msg="erroe:".$e->getMessage()."\n"; $msg.=$e->getTraceAsString()."\n"; $msg.='异常行号:'.$e->getLine()."\n"; $msg.="所在文件:".$e->getFile()."\n"; //将异常写入日志中 file_put_contents('error.log',$msg); }
    查看全部
  • echo "<hr />"; class myfunction extends Exception{ function getInformation(){ return "有错误,错误为:0001"; } } try { throw new myfunction('error');//创建一个对象 } catch(Exception $e){ echo $e->getInformation();//对象调用自定义的类方法 }
    查看全部
  • <?php $img=imagecreatetruecolor(100,50);//创建画布 $black=imagecolorallocate($img,0x00,0x00,0x00);//设置color $green=imagecolorallocate($img,0x00,0xff,0x00); $white=imagecolorallocate($img,0xff,0xff,0xff); imagefill($img,0,0,$white);//填充背景色 $code=''; for($i=0;$i<4;$i++){ $code.=rand(0,9);//生成随机的0-9,四位数字组合 } imagestring($img,5,10,10,$code,$green);//写字到图片上 //加入噪点干扰 for($i=0;$i<50;$i++){ imagesetpixel($img,rand(0,100),rand(0,100),$black);//画一个像素的点 imagesetpixel($img,rand(0,100),rand(0,100),$green); } //输出验证码 header("content-type:image/png"); imagepng($img); imagedestroy($img);//销毁图片资源,释放 ?>
    查看全部
    0 采集 收起

    2018-03-22

  • 1,imagecreatetruecolor(x,y)创建一个宽x高y的真彩色的空白图片; 2,imagecolorallocate($img,R,G,B)根据RGB颜色值确定画笔的颜色; 3,imageline($img,x1,y1,x2,y2,$color)通过坐标连接两点画线,原点(0,0)为图片左上角; 4,通过header("content-type:image/png")和imagepng()输入图像; 5,imagepng()可以将图像保存在指定文件中 imagepng($img, 'img.png')
    查看全部
    0 采集 收起

    2018-03-22

  • <?php echo date("Y-m-d H:i:s");echo "<br />"; echo gmdate("Y-m-d H:i:s");//相差8小时 ?>
    查看全部
    0 采集 收起

    2018-03-22

  • <?php echo "<br />"; date_default_timezone_set("Asia/ShangHai");//设置默认时区是中国 echo strtotime('2015-10-10');//将某时刻时间解析为时间戳 ?>
    查看全部
    0 采集 收起

    2018-03-22

  • <?php $file=__FILE__; foreach(glob("*") as $file){//循环删除目录中所有文件,然后再删除目录 unlink($filename); } ?>
    查看全部
  • <?php $file=__FILE__; $size=filesize($file); echo $size; echo "<hr />"; function getsize($size,$format='kb'){//定义函数 $p=0; if($format=='kb'){ $p=1; }else if($format=='mb'){ $p=2; }else if($format=='gb'){ $p=3; } $size=$size/pow(1024,$p); return number_format($size,3); } $size=filesize($file); $size=getsize($size,'kb');//值得注意的是,没法通过简单的函数来取得目录的大小,目录的大小是该目录下所有子目录以及文件大小的总和,因此需要通过递归的方法来循环计算目录的大小。 echo $size.'kb'; ?>
    查看全部
  • <?php $file=__FILE__; echo "所有者:".fileowner($file)."<br />"; echo "创建时间:".filectime($file)."<br />"; echo "修改时间:".filemtime($file)."<br />"; echo "最后访问时间:".fileatime($file)."<br />"; echo "修改时间:".date('Y-m-d H:i:s'); filemtime($filename); ?>
    查看全部
  • <?php $fp1=fopen($filename,'w'); fwrite($fp1,'您好'); echo file_get_contents($filename); fclose($filename); echo "<hr />"; ?> <?php $fp1=fopen($filename,'w'); fwrite($fp1,'大家好'); echo file_get_contents($filename); fclose($filename); echo "<hr />"; ?> <?php $fp1=fopen($filename,'w'); $arr=array('name'=>'user','age'=>18); var_dump($arr); fwrite($fp1,serialize($arr));//写入,数组,先得序列化 var_dump(file_get_contents($filename)); echo "<hr />"; file_put_contents($filename,$arr);//写入 var_dump(file_get_contents($filename,serialize($arr)));//与上面结果不一样 ?>
    查看全部
  • bool imagecopy( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y,   int src_w, int src_h )   参数说明:参数说明   dst_im目标图像   src_im被拷贝的源图像   dst_x目标图像开始 x 坐标   dst_y目标图像开始 y 坐标,x,y同为 0 则从左上角开始   src_x拷贝图像开始 x 坐标   src_y拷贝图像开始 y 坐标,x,y同为 0 则从左上角开始拷贝   src_w(从 src_x 开始)拷贝的宽度   src_h(从 src_y 开始)拷贝的高度
    查看全部
    0 采集 收起

    2015-10-23

  • <?php $filename1=__FILE__; if(is_file($filename1)){ // echo file_get_contents($filename1); echo "is_file ";echo "<br />"; } if(file_exists($filename1)){ echo "file_exists";echo "<br />"; } if(is_readable($filename1)){ echo "file is_readable";echo "<br />"; } if(is_writeable($filename1)){ echo "file is_writeable";echo "<br />"; } ?>
    查看全部
  • <?php echo __FILE__; echo "<br />"; $content1=file_get_contents(__FILE__,null,null,10,260); echo $content1; echo "<hr />"; $fp=fopen(__FILE__,'r'); while(!feof($fp)){ echo fgets($fp);//读取 } fclose($fp); ?>
    查看全部
  • image(png|jpeg|gif)()可将图像保存至不同格式的文件中
    查看全部
    0 采集 收起

    2015-10-23

  • imagestring($img,$fontSize,$x,$y,$str,$color),$fontSize并不是直接的字号,只有5种值(1,2,3,4,5),分别对应不同的字号
    查看全部
    0 采集 收起

    2015-10-23

举报

0/150
提交
取消
课程须知
需要有一定的网页基础知识如HTML、CSS样式等,并且已经学习完成《PHP入门篇》对PHP已经有了简单的了解,如变量、常量、数据类型等。
老师告诉你能学到什么?
全面的掌握PHP的理论知识与实践中的应用方法,提高编程能力与掌握网页开发技能。
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!