【发布时间】:2012-04-30 02:38:07
【问题描述】:
我想或者我更喜欢用 Php 指明函数中参数的真实类型,这可能吗?
例子:
<?php
function test($param)
{
echo $param;
}
$str = "hiiiii everyone";
test($str);
?>
不要只把 $param 放在函数测试中;我想放这样的东西
function test(string $param) // string is the type of the param, that can be int, long ect or an object which I had created.
使用最新版本的 PHP 可以做到这一点吗?
【问题讨论】:
-
@Jonathan Sampson:谢谢 :-)
-
Documentationisyourfriend。阅读。爱它。使用它。
-
看起来像是一个小葡萄干把问题打出来了,我们在这里是成年人(我假设(可能是错误的))