Heim Backend-Entwicklung PHP-Tutorial PHP文件夹遍历,图片等比例压缩

PHP文件夹遍历,图片等比例压缩

Jul 25, 2016 am 08:42 AM

  1. /**
  2. * 来源:互联网
  3. */
  4. class image
  5. {
  6. var $w_pct = 100; //透明度
  7. var $w_quality = 100; //质量
  8. var $w_minwidth = 500; //最小宽
  9. var $w_minheight = 500; //最小高
  10. var $interlace = 0; //图像是否为隔行扫描的
  11. var $fontfile ; //字体文件
  12. var $w_img ; //默认水印图
  13. function __construct()
  14. {
  15. $this->fontfile = $_SERVER['DOCUMENT_ROOT'].'/public/fonts/simhei.ttf';
  16. $this->w_img = '';
  17. }
  18. function image()
  19. {
  20. $this->__construct();
  21. }
  22. function info($img)
  23. {
  24. $imageinfo = getimagesize($img); //返回图像信息数组 0=>宽的像素 1=>高的像素 2=>是图像类型的标记 3 =>是文本字符串,内容为“height="yyy" width="xxx"”,
  25. if($imageinfo === false) return false;
  26. $imagetype = strtolower(substr(image_type_to_extension($imageinfo[2]),1)); //获取图像文件类型 $imageinfo[2]是图像类型的标记
  27. $imagesize = filesize($img); //图像大小
  28. $info = array(
  29. 'width'=>$imageinfo[0],
  30. 'height'=>$imageinfo[1],
  31. 'type'=>$imagetype,
  32. 'size'=>$imagesize,
  33. 'mime'=>$imageinfo['mime']
  34. );
  35. return $info;
  36. }
  37. /**
  38. * 缩略图
  39. *
  40. * @param string $image
  41. * @param string $filename
  42. * @param int $maxwidth
  43. * @param int $maxheight
  44. * @param string $suffix
  45. * @param int $autocut
  46. * @return string
  47. */
  48. function thumb($image, $filename = '',$maxwidth = 50, $maxheight = 50, $suffix='_thumb', $autocut = 0)
  49. {
  50. if( !$this->check($image)) return false;
  51. $info = $this->info($image); //获取图片信息
  52. if($info === false) return false;
  53. $srcwidth = $info['width']; //源图宽
  54. $srcheight = $info['height']; //源图高
  55. $pathinfo = pathinfo($image);
  56. $type = $pathinfo['extension']; //取得扩展名
  57. if(!$type) $type = $info['type']; //如果没有取到,用$info['type']
  58. $type = strtolower($type);
  59. unset($info);
  60. $scale = min($maxwidth/$srcwidth, $maxheight/$srcheight); //获取缩略比例
  61. //获取按照源图的比列
  62. $createwidth = $width = (int) ($srcwidth*$scale);//取得缩略宽();
  63. $createheight = $height = (int)($srcheight*$scale);//(); //取得缩略高
  64. $psrc_x = $psrc_y = 0;
  65. if($autocut) //按照缩略图的比例来获取
  66. {
  67. if($maxwidth/$maxheight=$height) //如果缩略图按比列比源图窄的话
  68. {
  69. $width = $maxheight/$height*$width; //宽按照相应比例做处理
  70. $height = $maxheight;// //高不变
  71. }
  72. elseif($maxwidth/$maxheight>$srcwidth/$srcheight && $maxwidth>=$width)//如果缩略图按比列比源图宽的话
  73. {
  74. $height = $maxwidth/$width*$height;//
  75. $width = $maxwidth;
  76. }
  77. if($maxwidth == '55'){
  78. $width = '55';
  79. $createwidth = '55';
  80. }
  81. if($maxwidth == '110'){
  82. $width = '110';
  83. $createwidth = '110';
  84. }
  85. }
  86. if($srcwidth $createwidth= $srcwidth;
  87. $createheight = $srcheight;
  88. }
  89. $createfun = 'imagecreatefrom'.($type=='jpg' ? 'jpeg' : $type); //找到不同的图像处理函数
  90. $srcimg = $createfun($image); //返回图像标识符
  91. if($type != 'gif' && function_exists('imagecreatetruecolor')){
  92. $thumbimg = imagecreatetruecolor($createwidth, $createheight); //新建一个真彩色图像
  93. }else{
  94. if($maxwidth == '110' && $srcheight >= $srcwidth){
  95. $height1 = 72;
  96. $thumbimg = imagecreate($width, $height1); //新建一个基于调色板的图像
  97. }elseif ($maxwidth == '110' && $srcheight $width1 = 110;
  98. $thumbimg = imagecreate($width1, $height); //新建一个基于调色板的图像
  99. }else{
  100. $thumbimg = imagecreate($width, $height); //新建一个基于调色板的图像
  101. }
  102. }
  103. if(function_exists('imagecopyresampled')){ //重采样拷贝部分图像并调整大小,真彩
  104. //imagecopyresampled(新图,源图,新图左上角x距离,新图左上角y距离,源图左上角x距离,源图左上角y距离,新图宽,新图高,源图宽,源图高)
  105. if($maxwidth == '110' && $srcheight >= $srcwidth){
  106. $psrc_x = 0;
  107. $psrc_yz = $height/2;
  108. $psrc_y = $psrc_yz;
  109. $width = '110';
  110. }
  111. if($maxwidth == '110' && $srcheight >= $srcwidth && $srcheight>= '72' && $srcwidth $psrc_x = 0;
  112. $psrc_yz = $height/2;
  113. $psrc_y = $psrc_yz;
  114. $width = '110';
  115. }
  116. if($maxheight == '72' && $srcheight = '110'){
  117. $cha = ($maxheight-$srcheight)/2;
  118. $psrc_y = -($cha);
  119. $width = $srcwidth;
  120. $height = '72';
  121. $srcheight = '72';
  122. }
  123. imagecopyresampled($thumbimg, $srcimg, 0, 0, $psrc_x, $psrc_y, $width, $height, $srcwidth, $srcheight);
  124. }else{ //拷贝部分图像并调整大小,调色板
  125. imagecopyresized($thumbimg, $srcimg, 0, 0, $psrc_x, $psrc_y, $width, $height, $srcwidth, $srcheight);
  126. }
  127. if($type=='gif' || $type=='png')
  128. {
  129. //imagecolorallocate 为一幅图像分配颜色
  130. $background_color = imagecolorallocate($thumbimg, 0, 255, 0); // 给基于调色板的图像填充背景色, 指派一个绿色
  131. // imagecolortransparent 将某个颜色定义为透明色
  132. imagecolortransparent($thumbimg, $background_color); // 设置为透明色,若注释掉该行则输出绿色的图
  133. }
  134. // imageinterlace 激活或禁止隔行扫描
  135. if($type=='jpg' || $type=='jpeg') imageinterlace($thumbimg, $this->interlace);
  136. $imagefun = 'image'.($type=='jpg' ? 'jpeg' : $type);
  137. //imagejpeg imagegif imagepng
  138. if(empty($filename)) $filename = substr($image, 0, strrpos($image, '.')).$suffix.'.'.$type; //获取文件名
  139. //aaa.gif aaa_thumb.gif
  140. $imagefun($thumbimg, $filename); //新建图像
  141. imagedestroy($thumbimg); //销毁缩略图
  142. imagedestroy($srcimg); //销毁源图
  143. return $filename;
  144. }
  145. /**
  146. * 限制宽或高
  147. *
  148. * @param string $image
  149. * @param int $maxwidth
  150. * @param int $maxheight
  151. * @param string $suffix
  152. * @return string
  153. */
  154. function thumb3($image,$maxwidth = 0, $maxheight = 0, $suffix='_thumb')
  155. {
  156. if( !$this->check($image)) return false;
  157. $info = $this->info($image); //获取图片信息
  158. if($info === false) return false;
  159. $srcwidth = $info['width']; //源图宽
  160. $srcheight = $info['height']; //源图高
  161. $pathinfo = pathinfo($image);
  162. $type = $pathinfo['extension']; //取得扩展名
  163. if(!$type) $type = $info['type']; //如果没有取到,用$info['type']
  164. $type = strtolower($type);
  165. unset($info);
  166. if($maxwidth==0){
  167. $scale = $maxheight/$srcheight;
  168. if($scale $createwidth = $srcwidth*$scale;
  169. $createheight = $maxheight;
  170. }else{
  171. $createwidth = $srcwidth;
  172. $createheight = $srcheight;
  173. }
  174. }
  175. if($maxheight==0){
  176. $scale = $maxwidth/$srcwidth;
  177. if($scale $createwidth = $maxwidth;
  178. $createheight = $srcheight*$scale;
  179. }else{
  180. $createwidth = $srcwidth;
  181. $createheight = $srcheight;
  182. }
  183. }
  184. $psrc_x = $psrc_y = 0;
  185. $createfun = 'imagecreatefrom'.($type=='jpg' ? 'jpeg' : $type); //找到不同的图像处理函数
  186. $srcimg = $createfun($image); //返回图像标识符
  187. if($type != 'gif' && function_exists('imagecreatetruecolor')){
  188. $thumbimg = imagecreatetruecolor($createwidth, $createheight); //新建一个真彩色图像
  189. }else{
  190. $thumbimg = imagecreate($createwidth, $createheight); //新建一个基于调色板的图像
  191. }
  192. if(function_exists('imagecopyresampled')){ //重采样拷贝部分图像并调整大小,真彩
  193. //imagecopyresampled(新图,源图,新图左上角x距离,新图左上角y距离,源图左上角x距离,源图左上角y距离,新图宽,新图高,源图宽,源图高)
  194. imagecopyresampled($thumbimg, $srcimg, 0, 0, $psrc_x, $psrc_y, $createwidth, $createheight, $srcwidth, $srcheight);
  195. }else{ //拷贝部分图像并调整大小,调色板
  196. imagecopyresized($thumbimg, $srcimg, 0, 0, $psrc_x, $psrc_y, $createwidth, $createheight, $srcwidth, $srcheight);
  197. }
  198. if($type=='gif' || $type=='png')
  199. {
  200. //imagecolorallocate 为一幅图像分配颜色
  201. $background_color = imagecolorallocate($thumbimg, 0, 255, 0); // 给基于调色板的图像填充背景色, 指派一个绿色
  202. // imagecolortransparent 将某个颜色定义为透明色
  203. imagecolortransparent($thumbimg, $background_color); // 设置为透明色,若注释掉该行则输出绿色的图
  204. }
  205. // imageinterlace 激活或禁止隔行扫描
  206. if($type=='jpg' || $type=='jpeg') imageinterlace($thumbimg, $this->interlace);
  207. $imagefun = 'image'.($type=='jpg' ? 'jpeg' : $type);
  208. //imagejpeg imagegif imagepng
  209. $filename = substr($image, 0, strrpos($image, '.')).$suffix.'.'.$type; //获取文件名
  210. //aaa.gif aaa_thumb.gif
  211. $imagefun($thumbimg, $filename); //新建图像
  212. imagedestroy($thumbimg); //销毁缩略图
  213. imagedestroy($srcimg); //销毁源图
  214. return $filename;
  215. }
  216. /**
  217. * 生成特定尺寸缩略图 解决原版缩略图不能满足特定尺寸的问题 PS:会裁掉图片不符合缩略图比例的部分
  218. * @static
  219. * @access public
  220. * @param string $image 原图
  221. * @param string $type 图像格式
  222. * @param string $thumbname 缩略图文件名
  223. * @param string $maxWidth 宽度
  224. * @param string $maxHeight 高度
  225. * @param boolean $interlace 启用隔行扫描
  226. * @return void
  227. */
  228. static function thumb2($image, $thumbname, $type='', $maxWidth=200, $maxHeight=50, $interlace=true) {
  229. // 获取原图信息
  230. $info = Image::getImageInfo($image);
  231. if ($info !== false) {
  232. $srcWidth = $info['width'];
  233. $srcHeight = $info['height'];
  234. $type = empty($type) ? $info['type'] : $type;
  235. $type = strtolower($type);
  236. $interlace = $interlace ? 1 : 0;
  237. unset($info);
  238. $scale = max($maxWidth / $srcWidth, $maxHeight / $srcHeight); // 计算缩放比例
  239. //判断原图和缩略图比例 如原图宽于缩略图则裁掉两边 反之..
  240. if($maxWidth / $srcWidth > $maxHeight / $srcHeight){
  241. //高于
  242. $srcX = 0;
  243. $srcY = ($srcHeight - $maxHeight / $scale) / 2 ;
  244. $cutWidth = $srcWidth;
  245. $cutHeight = $maxHeight / $scale;
  246. }else{
  247. //宽于
  248. $srcX = ($srcWidth - $maxWidth / $scale) / 2;
  249. $srcY = 0;
  250. $cutWidth = $maxWidth / $scale;
  251. $cutHeight = $srcHeight;
  252. }
  253. // 载入原图
  254. $createFun = 'ImageCreateFrom' . ($type == 'jpg' ? 'jpeg' : $type);
  255. $srcImg = $createFun($image);
  256. //创建缩略图
  257. if ($type != 'gif' && function_exists('imagecreatetruecolor'))
  258. $thumbImg = imagecreatetruecolor($maxWidth, $maxHeight);
  259. else
  260. $thumbImg = imagecreate($maxWidth, $maxHeight);
  261. // 复制图片
  262. if (function_exists("ImageCopyResampled"))
  263. imagecopyresampled($thumbImg, $srcImg, 0, 0, $srcX, $srcY, $maxWidth, $maxHeight, $cutWidth, $cutHeight);
  264. else
  265. imagecopyresized($thumbImg, $srcImg, 0, 0, $srcX, $srcY, $maxWidth, $maxHeight, $cutWidth, $cutHeight);
  266. if ('gif' == $type || 'png' == $type) {
  267. //imagealphablending($thumbImg, false);//取消默认的混色模式
  268. //imagesavealpha($thumbImg,true);//设定保存完整的 alpha 通道信息
  269. $background_color = imagecolorallocate($thumbImg, 0, 255, 0); // 指派一个绿色
  270. imagecolortransparent($thumbImg, $background_color); // 设置为透明色,若注释掉该行则输出绿色的图
  271. }
  272. // 对jpeg图形设置隔行扫描
  273. if ('jpg' == $type || 'jpeg' == $type)
  274. imageinterlace($thumbImg, $interlace);
  275. // 生成图片
  276. $imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
  277. @chmod(dirname($thumbname),0777);
  278. $imageFun($thumbImg, $thumbname);
  279. imagedestroy($thumbImg);
  280. imagedestroy($srcImg);
  281. return $thumbname;
  282. }
  283. return false;
  284. }
  285. /**
  286. * 取得图像信息
  287. * @static
  288. * @access public
  289. * @param string $image 图像文件名
  290. * @return mixed
  291. */
  292. static function getImageInfo($img) {
  293. $imageInfo = getimagesize($img);
  294. if ($imageInfo !== false) {
  295. $imageType = strtolower(substr(image_type_to_extension($imageInfo[2]), 1));
  296. $imageSize = filesize($img);
  297. $info = array(
  298. "width" => $imageInfo[0],
  299. "height" => $imageInfo[1],
  300. "type" => $imageType,
  301. "size" => $imageSize,
  302. "mime" => $imageInfo['mime']
  303. );
  304. return $info;
  305. } else {
  306. return false;
  307. }
  308. }
  309. //watermark(源图,生成文件,生成位置,水印文件,水印文本,背景色)
  310. function watermark($source, $target = '', $w_pos = 9, $w_img = '', $w_text = '', $w_font = 12, $w_color = '#cccccc',$x='',$y='')
  311. {
  312. if( !$this->check($source)) return false;
  313. if(!$target) $target = $source;
  314. if ($w_img == '' && $w_text == '')
  315. $w_img = $this->w_img;
  316. $source_info = getimagesize($source);
  317. $source_w = $source_info[0]; //获取宽
  318. $source_h = $source_info[1]; //获取高
  319. if($source_w w_minwidth || $source_h w_minheight) return false; //宽和高达不到要求直接返回
  320. switch($source_info[2]) //新建图片
  321. {
  322. case 1 :
  323. $source_img = imagecreatefromgif($source);
  324. break;
  325. case 2 :
  326. $source_img = imagecreatefromjpeg($source);
  327. break;
  328. case 3 :
  329. $source_img = imagecreatefrompng($source);
  330. break;
  331. default :
  332. return false;
  333. }
  334. if(!empty($w_img) && file_exists($w_img)) //水印文件
  335. {
  336. $ifwaterimage = 1; //是否水印图
  337. $water_info = getimagesize($w_img); //水印信息
  338. $width = $water_info[0];
  339. $height = $water_info[1];
  340. switch($water_info[2])
  341. {
  342. case 1 :
  343. $water_img = imagecreatefromgif($w_img);
  344. break;
  345. case 2 :
  346. $water_img = imagecreatefromjpeg($w_img);
  347. break;
  348. case 3 :
  349. $water_img = imagecreatefrompng($w_img);
  350. break;
  351. default :
  352. return;
  353. }
  354. }
  355. else
  356. {
  357. $ifwaterimage = 0;
  358. //imagettfbbox 本函数计算并返回一个包围着 TrueType 文本范围的虚拟方框的像素大小。
  359. //imagettfbbox ( 字体大小, 字体角度, 字体文件,文件 )
  360. // echo $this->fontfile;
  361. $temp = imagettfbbox(ceil($w_font*1.6), 0, $this->fontfile, $w_text);//取得使用 truetype 字体的文本的范围
  362. $width = $temp[4] - $temp[6]; //右上角 X 位置 - 左上角 X 位置
  363. $height = $temp[3] - $temp[5]; //右下角 Y 位置- 右上角 Y 位置
  364. unset($temp);
  365. }
  366. switch($w_pos)
  367. {
  368. case 0: //随机位置
  369. $wx = rand(0,($source_w - $width));
  370. $wy = rand(0,($source_h - $height));
  371. break;
  372. case 1: //左上角
  373. $wx = 25;
  374. $wy = 25;
  375. break;
  376. case 2: //上面中间位置
  377. $wx = ($source_w - $width) / 2;
  378. $wy = 0;
  379. break;
  380. case 3: //右上角
  381. $wx = $source_w - $width;
  382. $wy = 0;
  383. break;
  384. case 4: //左面中间位置
  385. $wx = 0;
  386. $wy = ($source_h - $height) / 2;
  387. break;
  388. case 5: //中间位置
  389. $wx = ($source_w - $width) / 2;
  390. $wy = ($source_h - $height) / 2;
  391. break;
  392. case 6: //底部中间位置
  393. $wx = ($source_w - $width) / 2;
  394. $wy = $source_h - $height;
  395. break;
  396. case 7: //左下角
  397. $wx = 0;
  398. $wy = $source_h - $height;
  399. break;
  400. case 8: //右面中间位置
  401. $wx = $source_w - $width;
  402. $wy = ($source_h - $height) /2;
  403. break;
  404. case 9: //右下角
  405. $wx = $source_w - $width;
  406. $wy = $source_h - $height ;
  407. break;
  408. default: //随机
  409. $wx = rand(0,($source_w - $width));
  410. $wy = rand(0,($source_h - $height));
  411. break;
  412. case 10://自定义位置
  413. $wx = $x;
  414. $wy = $y;
  415. case 11: //底部中间位置--手工客专用
  416. $wx = ($source_w - $width) / 2;
  417. $wy = $source_h - $height-50;
  418. break;
  419. break;
  420. }
  421. if($ifwaterimage) //如果有水印图
  422. {
  423. //imagecopymerge 拷贝并合并图像的一部分
  424. //参数(源图,水印图,拷贝到源图x位置,拷贝到源图y位置,从水印图x位置,从水印图y位置,高,宽,透明度)
  425. //imagecopymerge($source_img, $water_img, $wx, $wy, 0, 0, $width, $height, $this->w_pct);
  426. imagecopy($source_img,$water_img,$wx,$wy,0,0,$width,$height);
  427. }
  428. else
  429. {
  430. if(!empty($w_color) && (strlen($w_color)==7))
  431. {
  432. $r = hexdec(substr($w_color,1,2)); //获取红色
  433. $g = hexdec(substr($w_color,3,2)); //获取绿色
  434. $b = hexdec(substr($w_color,5)); //获取蓝色
  435. }
  436. else
  437. {
  438. return;
  439. }
  440. //imagecolorallocate 基于调色板的图像填充背景色
  441. //imagestring 水平地画一行字符串
  442. //imagestring(源图,字体大小,位置X,位置Y,文字,颜色)
  443. //参数($image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text)
  444. imagettftext($source_img,$w_font,0,$wx,$wy,imagecolorallocate($source_img,$r,$g,$b),$this->fontfile,$w_text);
  445. //imagestring($source_img,$w_font,$wx,$wy,$w_text,imagecolorallocate($source_img,$r,$g,$b));
  446. }
  447. //输出到文件或者浏览器
  448. switch($source_info[2])
  449. {
  450. case 1 :
  451. imagegif($source_img, $target); //以 GIF 格式将图像输出到浏览器或文件
  452. break;
  453. case 2 :
  454. imagejpeg($source_img, $target, $this->w_quality); //以 JPEG 格式将图像输出到浏览器或文件
  455. break;
  456. case 3 :
  457. imagepng($source_img, $target); //以 PNG 格式将图像输出到浏览器或文件
  458. break;
  459. default :
  460. return;
  461. }
  462. if(isset($water_info))
  463. {
  464. unset($water_info); //销毁
  465. }
  466. if(isset($water_img))
  467. {
  468. imagedestroy($water_img); //销毁
  469. }
  470. unset($source_info);
  471. imagedestroy($source_img);
  472. return true;
  473. }
  474. //gd库必须存在,后缀为jpg|jpeg|gif|png,文件存在,imagecreatefromjpeg或者imagecreatefromgif存在
  475. function check($image)
  476. {
  477. return extension_loaded('gd') &&
  478. preg_match("/\.(JPG|JPEG|PNG|GIF|jpg|jpeg|gif|png)/i", $image, $m) &&
  479. file_exists($image) &&
  480. function_exists('imagecreatefrom'.($m[1] == 'jpg' ? 'jpeg' : $m[1]));
  481. //imagecreatefromjpeg
  482. //imagecreatefromgif
  483. //imagecreatefrompng
  484. }
  485. }
  486. /**
  487. 缩略图
  488. 1.新建一个图像资源 通过 imagecreatefromgif imagecreatefromjpeg imagecreatefrompng
  489. 2.imagecopyresampled 拷贝图像,并调整大小
  490. 水印:图片水印,文字水印
  491. 1. 创建图像
  492. 2.加水印
  493. 图片水印:imagecopymerge 把2张图合并在一起
  494. 文字水印:imagettftext 向图像写入文字
  495. */
  496. error_reporting(0);
  497. $hostdir = dirname(__FILE__);
  498. $filesnames = scandir($hostdir.'/desktop');
  499. $img = new image();
  500. foreach($filesnames as $name){
  501. if($name != '.' && $name != '..'){
  502. $imgPath = $hostdir.'/desktop/';
  503. $imgsize = getimagesize($imgPath.$name);
  504. $imgInfo = explode('.',$name);
  505. $imginfo2 = explode('_',$imgInfo[0]);
  506. if($imginfo2[count($imginfo2)-1] != 'small'){
  507. $img_small = $imgPath.$imgInfo[0].'_small.'.$imgInfo[1];
  508. $img->thumb2($imgPath.$name,$img_small,'',$imgsize[0]/4,$imgsize[1]/4);
  509. }
  510. }
  511. }
复制代码

等比例, PHP


Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

Video Face Swap

Video Face Swap

Tauschen Sie Gesichter in jedem Video mühelos mit unserem völlig kostenlosen KI-Gesichtstausch-Tool aus!

Heißer Artikel

<🎜>: Bubble Gum Simulator Infinity - So erhalten und verwenden Sie Royal Keys
3 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusionssystem, erklärt
4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Flüstern des Hexenbaum
3 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

Java-Tutorial
1670
14
PHP-Tutorial
1273
29
C#-Tutorial
1256
24
Erklären Sie sicheres Kennwort -Hashing in PHP (z. B. password_hash, password_verify). Warum nicht MD5 oder SHA1 verwenden? Erklären Sie sicheres Kennwort -Hashing in PHP (z. B. password_hash, password_verify). Warum nicht MD5 oder SHA1 verwenden? Apr 17, 2025 am 12:06 AM

In PHP sollten die Funktionen für Passwort_Hash und passwart_verify verwendet werden, um sicheres Passwort -Hashing zu implementieren, und MD5 oder SHA1 sollte nicht verwendet werden. 1) Passwort_hash generiert einen Hash, der Salzwerte enthält, um die Sicherheit zu verbessern. 2) Passwort_Verify prüfen Sie das Passwort und sicherstellen Sie die Sicherheit, indem Sie die Hash -Werte vergleichen. 3) MD5 und SHA1 sind anfällig und fehlen Salzwerte und sind nicht für die Sicherheit der modernen Passwort geeignet.

PHP und Python: Vergleich von zwei beliebten Programmiersprachen PHP und Python: Vergleich von zwei beliebten Programmiersprachen Apr 14, 2025 am 12:13 AM

PHP und Python haben jeweils ihre eigenen Vorteile und wählen nach den Projektanforderungen. 1.PHP ist für die Webentwicklung geeignet, insbesondere für die schnelle Entwicklung und Wartung von Websites. 2. Python eignet sich für Datenwissenschaft, maschinelles Lernen und künstliche Intelligenz mit prägnanter Syntax und für Anfänger.

PHP in Aktion: Beispiele und Anwendungen in realer Welt PHP in Aktion: Beispiele und Anwendungen in realer Welt Apr 14, 2025 am 12:19 AM

PHP wird in E-Commerce, Content Management Systems und API-Entwicklung häufig verwendet. 1) E-Commerce: Wird für die Einkaufswagenfunktion und Zahlungsabwicklung verwendet. 2) Content -Management -System: Wird für die Erzeugung der dynamischen Inhalte und die Benutzerverwaltung verwendet. 3) API -Entwicklung: Wird für die erholsame API -Entwicklung und die API -Sicherheit verwendet. Durch Leistungsoptimierung und Best Practices werden die Effizienz und Wartbarkeit von PHP -Anwendungen verbessert.

Wie funktioniert der Php -Typ -Hinweis, einschließlich Skalartypen, Rückgabetypen, Gewerkschaftstypen und nullbaren Typen? Wie funktioniert der Php -Typ -Hinweis, einschließlich Skalartypen, Rückgabetypen, Gewerkschaftstypen und nullbaren Typen? Apr 17, 2025 am 12:25 AM

PHP -Typ -Eingabeaufforderungen zur Verbesserung der Codequalität und der Lesbarkeit. 1) Tipps zum Skalartyp: Da Php7.0 in den Funktionsparametern wie int, float usw. angegeben werden dürfen. 3) Eingabeaufforderung für Gewerkschaftstyp: Da Php8.0 in Funktionsparametern oder Rückgabetypen angegeben werden dürfen. 4) Nullierstyp Eingabeaufforderung: Ermöglicht die Einbeziehung von Nullwerten und Handlungsfunktionen, die Nullwerte zurückgeben können.

Die dauerhafte Relevanz von PHP: Ist es noch am Leben? Die dauerhafte Relevanz von PHP: Ist es noch am Leben? Apr 14, 2025 am 12:12 AM

PHP ist immer noch dynamisch und nimmt immer noch eine wichtige Position im Bereich der modernen Programmierung ein. 1) Einfachheit und leistungsstarke Unterstützung von PHP machen es in der Webentwicklung weit verbreitet. 2) Seine Flexibilität und Stabilität machen es ausstehend bei der Behandlung von Webformularen, Datenbankoperationen und Dateiverarbeitung; 3) PHP entwickelt sich ständig weiter und optimiert, geeignet für Anfänger und erfahrene Entwickler.

PHP und Python: Verschiedene Paradigmen erklärt PHP und Python: Verschiedene Paradigmen erklärt Apr 18, 2025 am 12:26 AM

PHP ist hauptsächlich prozedurale Programmierung, unterstützt aber auch die objektorientierte Programmierung (OOP). Python unterstützt eine Vielzahl von Paradigmen, einschließlich OOP, funktionaler und prozeduraler Programmierung. PHP ist für die Webentwicklung geeignet, und Python eignet sich für eine Vielzahl von Anwendungen wie Datenanalyse und maschinelles Lernen.

Wie verhindern Sie die SQL -Injektion in PHP? (Vorbereitete Aussagen, PDO) Wie verhindern Sie die SQL -Injektion in PHP? (Vorbereitete Aussagen, PDO) Apr 15, 2025 am 12:15 AM

Die Verwendung von Vorverarbeitungsanweisungen und PDO in PHP kann SQL -Injektionsangriffe effektiv verhindern. 1) Verwenden Sie PDO, um eine Verbindung zur Datenbank herzustellen und den Fehlermodus festzulegen. 2) Erstellen Sie Vorverarbeitungsanweisungen über die Vorbereitungsmethode und übergeben Sie Daten mit Platzhaltern und führen Sie Methoden aus. 3) Abfrageergebnisse verarbeiten und die Sicherheit und Leistung des Codes sicherstellen.

PHP und Python: Code Beispiele und Vergleich PHP und Python: Code Beispiele und Vergleich Apr 15, 2025 am 12:07 AM

PHP und Python haben ihre eigenen Vor- und Nachteile, und die Wahl hängt von den Projektbedürfnissen und persönlichen Vorlieben ab. 1.PHP eignet sich für eine schnelle Entwicklung und Wartung großer Webanwendungen. 2. Python dominiert das Gebiet der Datenwissenschaft und des maschinellen Lernens.

See all articles