gpt4 book ai didi

php - PHP 函数名是否区分大小写?

转载 作者:IT王子 更新时间:2023-10-29 01:18:31 24 4
gpt4 key购买 nike

我来自 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() */

任何人都可以清除我的疑问,为什么这也称为不区分大小写的函数名称。请告诉我如何在 PHP 中进行限制?

提前致谢。

最佳答案

它们不区分大小写,看这个:

Note: Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.

http://www.php.net/manual/en/functions.user-defined.php

关于php - PHP 函数名是否区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20344972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com