<?php
/**
* @throws Exception
*/
function curl()
{
throw new \Exception('errr');
}
/**
* getUserInfo
*/
function getUserInfo()
{
try
{
curl();
return true;
}
catch (Exception $exception)
{
return true;
}
finally
{
return false;
}
}
$rel = getUserInfo();
var_dump($rel);finally一定会被执行
finally中return会覆盖try和catch的return
面试中PHP面试官会问调用一个不存在的方法,如何知道是哪个文件哪行调用的?假设方法是getWorkLoad()回答1:开启PHP错误输出,PHP会输出Fatal error: Call to undefined function getWorkLoad() in D:\wwwroot\thinkpa...
主要原理是通过PHP创建多个子进程,在子进程中发送进程闹钟信号,然后再监听闹钟信号中继续发送闹钟信号。同时通过父进程设置非阻塞运行。代码如下:<?php /** * 订单任务 */ class Order { &n...
php7新增的特性(1).强制限制只能返回一种类型<?php class task { } //must return an integer function add(): int { &nb...
将jsonp转为PHP数组和对象。/** * jsonp转数组|Jsonp转json * @param string $jsonp jsonp字符串 * @param bool $as...
第一次听说端口复用是在mixphp最新版本中发现的,mixphp启动监听9501端口,现在作者说可以多开几个进程来执行mixphp,我心里想了下再启动不是会端口冲突嘛,但是却没有问题,于是下载mixphp的源码解读,原来是启动http服务器使用new Co\Http\Server('0.0....
php生成器的方法getReturn获取生成器迭代完成后的返回值,当生成器迭代完成会将生成器的返回值返回,因此如果迭代器未进行迭代是获取不到值的,如果你没有return值则返回null,参考代码:<?php function G1() { &nbs...