php SMTP发送邮件

php SMTP发送邮件

<?php /* SMTP Class * Example: * $x = new SMTP('smtp.qq.com',25,true,'kenvix@qq.com','*************'); * $x->send('God.Kenvix <kenvix@vip.qq.com>','God.Kenvix <kenvix@qq.com>','f','fff'); */ class SMTP { public $smtp_port; public $time_out; public $host_name; ...

PHP 2020-02-18 PM 2981℃ 0条
php 判断 Json 字符串

php 判断 Json 字符串

/** * @param string $data Json 字符串 * @param bool $assoc 是否返回关联数组 * @return bool|array 成功返回转换后的数组,否则返回 false */ function isJson($data = '', $assoc = false) { $data = json_decode($data, $assoc); if (is_array($data) && !empty(current($data))) { return $data; } r...

PHP 2020-02-18 PM 3675℃ 0条
php 计算几分钟前、几小时前、几天前、几月前、几年前

php 计算几分钟前、几小时前、几天前、几月前、几年前

/** * 计算几分钟前、几小时前、几天前、几月前、几年前。 * $agoTime string Unix时间 * @author tangxinzhuan * @version 2016-10-28 */ function smartDate($agoTime) { $agoTime = (int)$agoTime; // 计算出当前日期时间到之前的日期时间的毫秒数,以便进行下一步的计算 $time = time() - $agoTime; if ($time >= 31104000) { // N年前 ...

PHP 2020-02-18 PM 3697℃ 0条
php 页面跳转

php 页面跳转

/** * 页面跳转 */ function emDirect($directUrl) { header("Location: $directUrl"); exit; }

PHP 2020-02-18 PM 3636℃ 0条
php删除文件或目录

php删除文件或目录

/** * 删除文件或目录 */ function emDeleteFile($file) { if (empty($file)) return false; if (@is_file($file)) return @unlink($file); $ret = true; if ($handle = @opendir($file)) { while ($filename = @readdir($handle)) { if ($filename == '.' || $filename...

PHP 2020-02-18 PM 3399℃ 0条
php生成一个随机的字符串

php生成一个随机的字符串

/** * 生成一个随机的字符串 * * @param int $length * @param boolean $special_chars * @return string */ function getRandStr($length = 12, $special_chars = true) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; if ($special_chars) { $chars .= '!@#$%^&*()';...

PHP 2020-02-18 PM 3052℃ 0条
php获取文件名后缀

php获取文件名后缀

/** * 获取文件名后缀 */ function getFileSuffix($fileName) { return strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); }

PHP 2020-02-18 PM 3453℃ 0条
php转换附件大小单位

php转换附件大小单位

/** * 转换附件大小单位 * * @param string $fileSize 文件大小 kb */ function changeFileSize($fileSize) { if ($fileSize >= 1073741824) { $fileSize = round($fileSize / 1073741824, 2) . 'GB'; } elseif ($fileSize >= 1048576) { $fileSize = round($fileSize / 1048576, 2) . 'MB'; ...

PHP 2020-02-18 PM 2675℃ 0条
PHP截取编码为utf8的字符串

PHP截取编码为utf8的字符串

/**截取编码为utf8的字符串 *@param string $strings 预处理字符串@param int $start 开始处 eg:0@param int $length 截取长度 */function subString($strings, $start, $length) {if (function_exists('mb_substr') && function_exists('mb_strlen')) { $sub_str = mb_substr($strings, $start, $length, 'utf8'); return mb_...

公告 2020-02-18 PM 3164℃ 0条
php验证email地址格式

php验证email地址格式

/** * 验证email地址格式 */ function checkMail($email) { if (preg_match("/^[\w\.\-]+@\w+([\.\-]\w+)*\.\w+$/", $email) && strlen($email) <= 60) { return true; } else { return false; } }

PHP 2020-02-18 PM 4295℃ 0条
PHP检测是否为IP

PHP检测是否为IP

/** * 检测是否为IP * @param [type] $ip [description] * @return [type] [description] */ function funip($ip){ //IP正则匹配 //0.0.0.0--- 255.255.255.255 $pat = "/^(((1?\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((1?\d{1,2})|(2[0-4]\d)|(25[0-5]))$/"; if(preg_match($pat,$ip)){ $...

PHP 2020-02-18 PM 3043℃ 0条