我来自Java背景.在Java中,每个方法在调用时都区分大小写.但在PHP中,我在调用函数时没有看到区分大小写的函数名.
class Sample {
...
...
function sampleFunction() {
....
....
}
}
$obj = new Sample();
$obj->sampleFunction(); /* Proper call with function name */
$obj->samplefunction(); /* It should show undefined function error but it also calls sampleFunction() */
Run Code Online (Sandbox Code Playgroud)
任何人都可以清楚我的疑问为什么这甚至也称为非区分大小写的函数名称.请告诉我如何限制PHP?
提前致谢.
小智 42
它们不区分大小写,请看:
注意:函数名称不区分大小写,尽管调用函数通常是在声明中出现的良好形式.
http://www.php.net/manual/en/functions.user-defined.php
Pan*_*eek 13
函数不区分大小写,变量区分大小写.
你可以从手册阅读更多信息:
http://fr.php.net/manual/en/functions.user-defined.php