PHP日常知识点
PerfectUrl
PHP 项目开发,Go项目开发
展开
-
laravel php画图出现乱码
ob_clean(); ob_start(); $imgUrl = public_path() . "\\excel_bg.png"; $im = imagecreatefrompng($imgUrl); $black = imagecolorallocate($im, 0, 0, 0); imagepng($im); imagedestroy($im); $content =...原创 2020-12-18 10:53:46 · 285 阅读 · 1 评论 -
phpstudy本地开发解决larave 404问题
server { listen 80; server_name shiliyoupin.com; root "F:\PhpProject\shiliyoupin\public"; location / { index index.php index.html error/index.html; error_page 400 /error/400.html; ...原创 2020-09-10 10:00:36 · 670 阅读 · 0 评论 -
PHP-curl封装
<?php/** * Notes: 封装PHPCurl请求 */ function network_request($url, $data = null, $method = 'get', $jsonFormat = true, $header = '', $https = false, $timeout = 15) { $method...原创 2019-11-28 11:25:08 · 258 阅读 · 0 评论 -
PHP实现二分查找,详解
/** * 注意:二分法的前提是,需要数组是有序的 */$arr_list = [10, 11, 14, 16, 18, 19, 21, 29, 30, 36, 38, 42, 43, 47, 49, 50, 53, 54, 57, 80, 84, 94, 96, 102, 105, 107, 120, 125, 129, 138, 139, 140, 150, 188, 190, 200...原创 2018-12-05 17:26:15 · 322 阅读 · 0 评论 -
php解析UTC时间
打印当前时间print_r(date("Y-m-d H:i:s")); //设置当前时间为UTC时间date_default_timezone_set("UTC"); //打印UTC时间print_r(date("Y-m-d H:i:s")); //获取当前的时间区域print_r(date_default_timezone_get());...原创 2019-01-10 15:34:50 · 1431 阅读 · 0 评论 -
PHP sgin加密和session防止用户多次提交
/**inc 解析接口客户端接口传输规则:1.用cmd参数(base64)来动态调用不同的接口,接口地址统一为 http://a.lovexpp.com2.将要传过来的参数组成一个数组,数组添加timestamp元素(当前时间戳,精确到秒),将数组的键值按照自然排序从大到小排序3.将数组组成 key=val&key=val的形式的字符串,将字符串与XPP_KEY连接在一起,用...翻译 2019-01-09 14:24:59 · 289 阅读 · 0 评论 -
php 树形递归操作
表结构CREATE TABLE `admin_menu` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `parent_id` int(11) NOT NULL DEFAULT '0', `order` int(11) NOT NULL DEFAULT '0', `title` varchar(50) COLLATE utf8...原创 2019-01-28 21:03:13 · 1351 阅读 · 0 评论 -
大牛技术文档链接
https://www.cnblogs.com/protected/p/6526857.html----数据库事务和隔离级别https://www.cnblogs.com/protected/p/6419217.html----内存分配及变量存储位置(堆、栈、方法区常量池、方法区静态区)https://segmentfault.com/a/1190000002424023#articl...转载 2019-06-14 13:36:50 · 189 阅读 · 0 评论 -
PHP经典单例模式封装
<?phptrait Singletons{ private static $instance; public static function getInstance(){ if(!isset(self::$instance)){ self::$instance = new static();//这里不能new self(),s...原创 2019-07-13 18:39:54 · 322 阅读 · 0 评论 -
PHP实现JWK
<?php//JWT JSON Web Token//Head 头部部分$header = array();$header["alg"] = "HS256";$header["typ"] = "JWT";$headerJson = json_encode($header);$headerEn = urlsafe_b64encode($headerJson);//Payl...原创 2019-07-28 16:49:04 · 1235 阅读 · 0 评论 -
composer PHP忽略版本控制
使用 composer install --ignore-platform-reqs 命令设置忽略版本匹配然后再进行安装你所需要的原创 2019-08-21 15:01:06 · 1102 阅读 · 0 评论 -
spl_autoload_register自动加载封装类
class autoload{ public static function __auto(){ spl_autoload_register("autoload::requireFile"); } public static function requireFile($classname){ echo $classname; ...原创 2018-12-05 11:14:17 · 297 阅读 · 0 评论 -
Laravel:从亚马逊s3上下载文件
public function down(Request $request){ $fileName = Redis::get(Lib_active_redis::ET_TASK_URL_CONFIG);//上传配置的名字 $savePath = $this->savePath() . $fileName; $exists = Storage::disk('s3')...原创 2018-11-20 14:46:16 · 1652 阅读 · 0 评论 -
PHP传递任意数量的函数参数
下面这个示例向你展示了PHP函数的默认参数: // 两个默认参数的函数 function foo($arg1 = ”, $arg2 = ”) { echo “arg1: $arg1\n”; echo “arg2: $arg2\n”; } foo(‘hello’,'world’); /* 输出: arg1: hello arg2: world翻译 2017-03-29 09:34:41 · 2851 阅读 · 0 评论 -
获得图片二进制流
上传图片翻译 2017-03-29 14:04:54 · 1239 阅读 · 0 评论 -
使用glob()查找文件
大部分PHP函数的函数名从字面上都可以理解其用途,但是当你看到 glob() 的时候,你也许并不知道这是用来做什么的,其实glob()和scandir() 一样,可以用来查找文件,请看下面的用法: $files = glob('../05-15/1*.php'); //指定目录的.php 文件// 取得所有的后缀为PHP的文件 $files = glob(‘*.php’);原创 2017-03-29 09:39:53 · 1012 阅读 · 0 评论 -
header 跳转
meta refresh示例5秒之后刷新本页面:5秒之后转到梦之都首页:2. PHP中使用header函数上面已经了解了HTML中写跳转(重定向)页面的代码php代码示例header('Refresh: 3; url=www.baidu.com');//三秒以后跳转百度原创 2017-04-22 22:03:32 · 3657 阅读 · 0 评论 -
PHP大文件下载
?php /** * Created by PhpStorm. * User: Kung * Date: 15-10-21 * Time: 下午8:00 */ set_time_limit(0); //大文件在读取内容未结束时会被超时处理,导致下载文件不全。 $fpath = 'the_file_path'; $file_pathin翻译 2017-04-25 10:39:45 · 745 阅读 · 0 评论 -
http_build_query用法
http_build_query(PHP 5)http_build_query -- 生成 url-encoded 之后的请求字符串描述string http_build_query ( array formdata [, string numeric_prefix] )使用给出的关联(或下标)数组生成一个 url-encoded 请求字符串。参数 formdata 可以是转载 2017-06-14 09:49:51 · 396 阅读 · 0 评论 -
ob_flush,flush 循环输出数字
print str_repeat(" ", 4096);//php.ini output_buffering默认是4069字符或者更大,即输出内容必须达到4069字符服务器才会flush刷新输出缓冲for ($i=10; $i>0; $i--){ echo $i; ob_flush(); flush(); sleep(1);}原创 2017-08-09 10:01:41 · 406 阅读 · 0 评论 -
自定义版本比较函数
$ver01 ='5.2.3.5'; $ver02 ='5.2.3.4'; function versionCompare($str01,$str02){ $arrA = explode('.', $str01);//将字符串转换成数字 $arrB = explode('.', $str02); $lenth = max(count(原创 2017-08-24 18:14:32 · 287 阅读 · 0 评论 -
If($i==true)和If(true==$i)区别
区别在于容易查错,当误把==号写作=号时,if ($i=true)不会报错,而且无论$i为何值都会成立,但是写成if (true=$i) 会报错,因为常量无法被赋值。在涉及==的逻辑表达式中,常量写在前面可以有效利用编译器查错机制避免类似 if ($i == true)这样的错误。至于实际功能上,没有任何区别原创 2017-08-24 14:22:52 · 821 阅读 · 0 评论 -
PHP起泡排序
$ arr = array(0,1,2,3,4,5,6,7,8,9); $ length = count($ arr); for($ i = 0; $ i <$ length-1; $ i ++){ for($ j = 0; $ j <$ length-1- $ i; $ j ++){ $ temp =“”; if($ arr [$ j] <...原创 2017-09-19 10:08:36 · 462 阅读 · 0 评论 -
Thinkphp 验证码
显示验证码首先在Home/Controller下创建一个公共控制器PublicController 1 php 2 namespace Home\Controller; 3 4 use Think\Controller; 5 use Think\Verify; 6 7 class PublicController extends Controller 8 {翻译 2017-03-28 20:13:51 · 546 阅读 · 0 评论