首页
关于
留言
友链
直播
更多
视频
壁纸
Search
1
乐橙CMS影视管理系统最全版本
20,298 阅读
2
新浪图片链接修复教程集合
12,970 阅读
3
乐橙CMS影视管理系统4.0.18版本
11,640 阅读
4
反调试代码调试死机代码禁止F12代码
6,840 阅读
5
爬虫UA大全
5,475 阅读
语言
PHP
Java
Go
JavaScript
CSS
Vue
资源教程
网络杂谈
技术文章
影视交流
软件工具
Mac
Search
标签搜索
PHP
LINUX
微信
MYSQL
P2P
JS
乐橙cms
支付
破解
公众号
typecho
xshell
扫一扫
监控
微信支付
支付宝
JetBrains
redis
VPN
MacBook
子沫'S
累计撰写
103
篇文章
累计收到
368
条评论
首页
栏目
语言
PHP
Java
Go
JavaScript
CSS
Vue
资源教程
网络杂谈
技术文章
影视交流
软件工具
Mac
页面
关于
留言
友链
直播
视频
壁纸
搜索到
7
篇与
PHP
的结果
2019-04-19
php多维数组排序
/** * 多维数组排序 * @param $multi_array * @param $sort_key * @param int $sort * @return array|bool */ function multi_array_sort($multi_array,$sort_key,$sort=SORT_ASC){ if(is_array($multi_array)){ foreach ($multi_array as $row_array){ if(is_array($row_array)){ $key_array[] = $row_array[$sort_key]; }else{ return false; } } }else{ return false; } array_multisort($key_array,$sort,$multi_array); return $multi_array; }
2019年04月19日
783 阅读
0 评论
0 点赞
2019-04-19
php把一个二维数组中的某个或者某些字段当成 key
/** * 把一个二维数组中的某个或者某些字段当成 key * * @param array $array 二维数组 * @param string|array $field 字段,liuchao 修改 * * @return array */ function useFieldAsArrayKey($array, $field) { $newArr = []; if (is_array($field)) { foreach ($array as $key => $value) { $newKey = ''; foreach ($field as $f) { $newKey .= $value[strval($f)]; } if (!isset($newArr[$newKey])) { $newArr[$newKey] = $value; } } } else { foreach ($array as $key => $value) { $newArr[$value[strval($field)]] = $value; } } return $newArr; }
2019年04月19日
1,084 阅读
0 评论
1 点赞
2019-04-19
以json类型的数据返回,第二个参数JSON_UNESCAPED_UNICODE
//以json类型的数据返回 function ajaxReturn($data){ header('Content-type: application/json'); echo json_encode($data,JSON_UNESCAPED_UNICODE); die(); }
2019年04月19日
968 阅读
0 评论
0 点赞
2019-04-19
php时区间时间转换,国外项目对时区的处理
//时区转换] /** * @param $date_time * @param string $format * @param string $to * @param string $from * @return string * wechat:weigo521 */ public function timeZoneTransform($date_time, $format = 'Y-m-d H:i:s', $to = 'America/New_York', $from = 'Asia/Shanghai') { $datetime = new \DateTime($date_time, new \DateTimeZone($from)); $datetime->setTimezone(new \DateTimeZone($to)); return $datetime->format($format); }
2019年04月19日
855 阅读
0 评论
0 点赞
2019-04-03
【基础】你知道PHP7有哪些新特性吗?以下总结希望能帮到你
PHP 7使用新的Zend Engine 3.0将应用程序性能提高近两倍,内存消耗比PHP 5.6高出50%。它允许服务更多的并发用户,而不###需要任何额外的硬件。PHP 7是考虑到今天的工作负载而设计和重构的。PHP新功能总结*改进的性能 - 将PHPNG代码合并到PHP7中,速度是PHP 5的两倍。*降低内存消耗 - 优化的PHP 7使用较少的资源。*标量类型声明 - 现在可以强制执行参数和返回类型。*一致的64位支持 - 对64位体系结构机器的一致支持。*改进了异常层次 - 异常层次得到了改进*许多致命的错误转换为例外 - 例外范围增加,涵盖许多致命的错误转换为例外。*安全随机数发生器 - 增加新的安全随机数发生器API。*已弃用的SAPI和扩展已删除 - 各种旧的和不受支持的SAPI和扩展从最新版本中删除。*空合并运算符(?) - 添加了新的空合并运算符。*返回和标量类型声明 - 支持所添加的返回类型和参数类型。*匿名类 - 支持匿名添加。*零成本断言 - 支持零成本断言增加。标量类型声明在PHP 7中,引入了一个新的特性,即标量类型声明。标量类型声明有两个选项*强制 - 强制是默认模式,不需要指定。*严格 - 严格的模式已经明确暗示。功能参数的以下类型可以使用上述模式强制执行*float*int*bool*string*interfaces*array*callable强制模式<?php // Coercive mode function sum(int ...$ints) { return array_sum($ints); } print(sum(2, '3', 4.1)); //9 ?>严格模式<?php // Strict mode declare(strict_types=1); function sum(int ...$ints) { return array_sum($ints); } print(sum(2, '3', 4.1)); //Fatal error: Uncaught TypeError: Argument 2 passed to sum() must be of the type integer, string given, ... ?>返回类型声明有效的返回类型<?php declare(strict_types = 1); function returnIntValue(int $value): int { return $value; } print(returnIntValue(5)); ?>无效返回类型<?php declare(strict_types = 1); function returnIntValue(int $value): int { return $value + 1.0; } print(returnIntValue(5));//Fatal error: Uncaught TypeError: Return value of returnIntValue() must be of the type integer, float returned. ?>空合并运算符在PHP 7中,引入了一个新的特性,即空合并运算符(??)。它用来替代与isset()函数结合的三元操作。该空如果它存在,而###不是空合并运算符返回第一个操作数; 否则返回第二个操作数。<?php // fetch the value of $_GET['user'] and returns 'not passed' // if username is not passed $username = $_GET['username'] ?? 'not passed'; print($username); print("<br/>"); // Equivalent code using ternary operator $username = isset($_GET['username']) ? $_GET['username'] : 'not passed'; print($username); print("<br/>"); // Chaining ?? operation $username = $_GET['username'] ?? $_POST['username'] ?? 'not passed'; print($username); // output //not passed ?>飞船运算符它用来比较两个表达式。当第一个表达式分别小于,等于或大于第二个表达式时,它返回-1,0或1。字符串比较ASCII//integer comparison print( 1 <=> 1);print("<br/>"); print( 1 <=> 2);print("<br/>"); print( 2 <=> 1);print("<br/>"); // output 0 -1 1常量数组使用define()函数定义数组常量。在PHP 5.6中,只能使用const关键字来定义它们。<?php //define a array using define function define('animals', [ 'dog', 'cat', 'bird' ]); print(animals[1]); // output cat ?>匿名类现在可以使用新类来定义匿名类。匿名类可以用来代替完整的类定义。<?php interface Logger { public function log(string $msg); } class Application { private $logger; public function getLogger(): Logger { return $this->logger; } public function setLogger(Logger $logger) { $this->logger = $logger; } } $app = new Application; $app->setLogger(new class implements Logger { public function log(string $msg) { print($msg); } }); $app->getLogger()->log("My first Log Message"); ?> //output My first Log MessageClosure类Closure :: call()方法被添加为一个简短的方式来临时绑定一个对象作用域到一个闭包并调用它。与PHP5的bindTo相比,###它的性能要快得多。在PHP 7之前<?php class A { private $x = 1; } // Define a closure Pre PHP 7 code $getValue = function() { return $this->x; }; // Bind a clousure $value = $getValue->bindTo(new A, 'A'); print($value()); //output 1 ?>PHP 7+<?php class A { private $x = 1; } // PHP 7+ code, Define $value = function() { return $this->x; }; print($value->call(new A)); //output 1 ?>过滤unserializePHP 7引入了过滤的unserialize()函数,以便在对不可信数据上的对象进行反序列化时提供更好的安全性。它可以防止可能###的代码注入,并使开发人员能够对可以反序列化的类进行白名单<?php class MyClass1 { public $obj1prop; } class MyClass2 { public $obj2prop; } $obj1 = new MyClass1(); $obj1->obj1prop = 1; $obj2 = new MyClass2(); $obj2->obj2prop = 2; $serializedObj1 = serialize($obj1); $serializedObj2 = serialize($obj2); // default behaviour that accepts all classes // second argument can be ommited. // if allowed_classes is passed as false, unserialize converts all objects into __PHP_Incomplete_Class object $data = unserialize($serializedObj1 , ["allowed_classes" => true]); // converts all objects into __PHP_Incomplete_Class object except those of MyClass1 and MyClass2 $data2 = unserialize($serializedObj2 , ["allowed_classes" => ["MyClass1", "MyClass2"]]); print($data->obj1prop); print("<br/>"); print($data2->obj2prop); //output 1 2 ?>IntlChar在PHP7中,增加了一个新的IntlChar类,它试图揭示额外的ICU功能。这个类定义了一些静态方法和常量,可以用来处理###Unicode字符。在使用这个课程之前,你需要安装Intl扩展。<?php printf('%x', IntlChar::CODEPOINT_MAX); print (IntlChar::charName('@')); print(IntlChar::ispunct('!')); //output 10ffff COMMERCIAL AT true ?>CSPRNG在PHP 7中,引入了两个新的函数来以跨平台的方式生成密码安全的整数和字符串。*random_bytes() - 生成密码安全的伪随机字节。*random_int() - 生成密码安全的伪随机整数<?php $bytes = random_bytes(5); print(bin2hex($bytes)); //output 54cc305593 print(random_int(100, 999)); print(""); print(random_int(-1000, 0)); //output 614 -882 ?>使用声明从PHP7开始,可以使用单个use语句从相同的命名空间导入类,函数和常量,而不是使用多个use语句。<?php // Before PHP 7 use com\tutorialspoint\ClassA; use com\tutorialspoint\ClassB; use com\tutorialspoint\ClassC as C; use function com\tutorialspoint\fn_a; use function com\tutorialspoint\fn_b; use function com\tutorialspoint\fn_c; use const com\tutorialspoint\ConstA; use const com\tutorialspoint\ConstB; use const com\tutorialspoint\ConstC; // PHP 7+ code use com\tutorialspoint\{ClassA, ClassB, ClassC as C}; use function com\tutorialspoint\{fn_a, fn_b, fn_c}; use const com\tutorialspoint\{ConstA, ConstB, ConstC}; ?>整数部分PHP 7引入了一个新的函数intdiv(),它对它的操作数进行整数除法,并将除法运算返回为int。<?php $value = intdiv(10,3); var_dump($value); print(" "); print($value); //output int(3) 3 ?>会话选项session_start()函数接受来自PHP7 + 的一系列选项来覆盖php.ini中设置的会话配置指令。这些选项支持###session.lazy_write,默认情况下,它会导致PHP在会话数据发生更改时覆盖任何会话文件。添加的另一个选项是read_and_close,它表示应该读取会话数据,然后应该立即关闭会话。例如,将session.cache_limiter设置为private,并使用以下代码片段将标志设置为在读取完毕后立即关闭会话。<?php session_start([ 'cache_limiter' => 'private', 'read_and_close' => true, ]); ?>弃用PHP 4样式构造函数是与它们定义的类具有相同名称的方法,现在已被弃用,并且将来将被删除。如果PHP 4的构造函数是类中定###义的唯一构造函数,则PHP 7将发出E_DEPRECATED。实现__construct()方法的类不受影响。<?php class A { function A() { print('Style Constructor'); } } ?>对非静态方法的静态调用已被弃用,并可能在将来被删除<?php class A { function b() { print('Non-static call'); } } A::b(); // Deprecated: Non-static method A::b() should not be called statically in...Non-static call ?>错误处理从PHP 7开始,错误处理和报告已经改变。而不是通过PHP 5使用的传统错误报告机制来报告错误,现在大多数错误都是通过抛出###错误异常来处理的。与异常类似,这些错误异常会一直冒泡,直到它们到达第一个匹配的catch块。如果没有匹配的块,则使用###set_exception_handler()安装的默认异常处理程序将被调用。如果没有默认的异常处理程序,那么异常将被转换为致命错误,并将像传统的错误一样处理。由于错误层次结构不是从Exception扩展的,所以使用catch(Exception $ e){...}块来处理PHP 5中未捕获的异常的代码将###不会处理这样的错误。catch(Error $ e){...}块或set_exception_handler()处理程序是处理致命错误所必需的。<?php class MathOperations { protected $n = 10; // Try to get the Division by Zero error object and display as Exception public function doOperation(): string { try { $value = $this->n % 0; return $value; } catch (DivisionByZeroError $e) { return $e->getMessage(); } } } $mathOperationsObj = new MathOperations(); print($mathOperationsObj->doOperation()); // output Modulo by zero ?>
2019年04月03日
718 阅读
0 评论
0 点赞
1
2