php声明空白类,如果我声明空白页(strict_types = 1);在PHP 7的顶部

最近我正在检查PHP 7,特别是

return type declaration和

type hinting.我已经从源代码编译了PHP 7(从

Github开始的master分支)并在Ubuntu 14.04虚拟框中运行它.我尝试运行以下代码来测试新的

Exceptions.但它给了一个空白页面.

function test(): string {

return [];

}

echo test();

然后我意识到我必须设置错误才能在屏幕上显示.所以我添加了老式的ini_set(‘display_errors’,1);如下,

ini_set('display_errors', 1);

function test(): string {

return [];

}

echo test();

根据这个Throwable interface RFC,这给了我按照预期的TypeError

Fatal error: Uncaught TypeError: Return value of test() must be of the

type string, array returned in /usr/share/nginx/html/test.php on line

7 in /usr/share/nginx/html/test.php:7 Stack trace: #0

/usr/share/nginx/html/test.php(10): test() #1 {main} thrown in

/usr/share/nginx/html/test.php on line 7

进一步挖掘我添加了declare(strict_types = 1);在顶部如下,

ini_set('display_errors', 1);

function test(): string {

return [];

}

echo test();

和爆炸,错误刚刚消失,留下我的空白页.我无法弄清楚为什么它给我一个空白页?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值