【发布时间】:2017-10-25 10:00:28
【问题描述】:
朋友。 我有以下代码:
<?php
function f(int $a)
{
return $a;
}
f("1a"); // get 1 and produce notice
f("aaa"); // produce TypeError ;
我使用 php 7.1
我预计,php 将根据http://php.net/manual/en/language.types.string.php#language.types.string.conversion 将字符串参数转换为 int 分别给我1和0。 但似乎还有其他规则,但我在文档中找不到。 这是什么规则,它在哪里描述?谢谢。
【问题讨论】:
标签: php casting integer arguments