This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 将数组写入ini文件。 | |
| * @param array $array 待写入的数组。 | |
| * @param string $file ini文件路径。 | |
| * @return bool | |
| */ | |
| function iniEditor($array, $file) | |
| { | |
| $res = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 图片的等比缩放 | |
| */ | |
| // 因为PHP只能对资源进行操作,所以要对需要进行缩放的图片进行拷贝,创建为新的资源。 | |
| $src = imagecreatefromjpeg('origin.jpg'); | |
| // 取得源图片的宽度和高度 | |
| $size_src = getimagesize('origin.jpg'); | |
| $w = $size_src['0']; | |
| $h = $size_src['1']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 给图片打水印。 | |
| */ | |
| // 原图 | |
| $dst = "bg.jpg"; | |
| $dst_im = imagecreatefromjpeg($dst); | |
| $dst_info = getimagesize($dst); | |
| // 水印图 | |
| $src = "shuiyin.jpg"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 获得memcached服务的状态信息。不需要额外的pecl扩展。 | |
| * @param string $host | |
| * @param int $port | |
| * @return array | |
| */ | |
| function getMemcachedStat($host, $port) | |
| { | |
| $s = fsockopen($host, $port, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 计算阶乘。注:解决了大数显示问题。 | |
| * | |
| * @param int $n | |
| * @return string | |
| */ | |
| function factorial($n) | |
| { | |
| if ($n < 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function download($sContent, $sFileName) | |
| { | |
| header("Content-type: application/octet-stream"); | |
| header("Accept-Length: " . mb_strlen($sContent)); | |
| header("Content-Disposition: attachment; filename=" . $sFileName); | |
| echo $sContent; | |
| } | |
| # end of this file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Colorful echo. | |
| * @param string $string The string you want to show. | |
| * @param string $style Color theme.It can be:notic, info, error, system. | |
| */ | |
| function cecho($string, $style = 'info') | |
| { | |
| if (PHP_SAPI !== 'cli') { | |
| echo $string, "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Prevent XSS. | |
| * Allowing you to add permmited tags or attributes. | |
| * | |
| * @author liuxd | |
| */ | |
| class XssFilter | |
| { | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 图片与字符串互相转换。 | |
| */ | |
| class ImgPipString | |
| { | |
| /** | |
| * 图片转字符串 | |
| * @param string $file 图片文件路径。 | |
| * @return string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $("input[name=input_name]:checked").val(); |