<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/10/13 * Time: 10:25 */ class ImportData{ //数据库信息 private $dbhost; private $dbuser; private $dbpw; private $dbport; private $dbname; private $dbcharset; private $link; private $tablepre;...
<?php function insert($file,$database,$name,$root,$pwd)// { //将表导入数据库 header("Content-type: text/html; charset=utf-8"); $_sql = file_get_contents($file);//写自己的.sql文件 $_arr = explode(';', $_sql); $_mysqli = new mysqli($name,$root,$pwd,$d...
<?php /* include _include(APP_PATH . 'model/chinese_spell.func.php'); $str = '取汉字所有拼音'; // 取全部拼音 echo get_full_spell($str); echo '<hr>'; // 取第一个字拼音 echo get_first_spell($str); * */ // 取全部拼音 function get_full_spell($str) { $chinese_spell = new chinese_spell(); $str = code_convers...
<?php // hook model_check_start.php function is_word($s) { // hook model_is_word_start.php $r = preg_match('#^\\w{1,32}$#', $s, $m); // hook model_is_word_end.php return $r; } function is_mobile($mobile, &$err) { // hook model_is_mobile_start.php if(!preg_match('...
PHP 修改本地配置文件/** * 修改本地配置文件 * * @param array $name ['配置名'] * @param array $value ['参数'] * @return void */ function setconfig($name, $value) { if (is_array($name) and is_array($value)) { for ($i = 0; $i < count($name); $i++) { $names[$i] = '/\'' . $name[$i] . '\'...
//生成随机用户名 function get_username() { $chars1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $chars2 = "abcdefghijklmnopqrstuvwxyz0123456789"; $username = ""; for ( $i = 0; $i < mt_rand(2,3); $i++ ) { $username .= $chars1[mt_rand(0,25)]; } $user...
PHP判断当前时间是否在指定时间段之内/** * 判断当前时间是否在指定时间段之内 * @param integer $a 起始时间 * @param integer $b 结束时间 * @return boolean */ function check_time($a,$b) { $nowtime = time(); $start = strtotime($a.':00:00'); $end = strtotime($b.':00:00'); if ($nowtime >= $end || $nowtime <= $start){ ...
PHP 常用函数 检查图片是不是bases64编码的function is_mobile($tel){ if(preg_match("/^1[345789]{1}\d{9}$/",$tel)){ return true; }else{ return false; } } /* * 检查图片是不是bases64编码的 */ function is_image_base64($base64) { if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $b...
基于阿里云(万网)域名检测接口<?php $result = whois('WWW.AEINK.COM'); $xml = simplexml_load_string($result); $code = is_register($xml->original); if ($code == 0) { echo '域名可以注册'; } else if ($code == 1) { echo '‘域名已经注册’'; } else { echo '‘域名参数传输错误’'; } function whois($domain) { // 创建一个新cURL资...
PHP 判断是否 URL 链接一、正则<?phpfunction is_url($url){$r = "/http[s]?:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is"; if(preg_match($r,$url)){ //return true; echo '正确的 url 地址'; }else{ //return false; echo '不是合法的 url 地址'; }}二、内置函数<?phpfunction is_url_2($url){if (filter_var($...