gpt4 book ai didi

如果变量传递给 empty() 或 isset(),PHP 不会对 undefined variable 发出任何通知

转载 作者:行者123 更新时间:2023-12-02 07:05:02 25 4
gpt4 key购买 nike

<?php

function myFunction($yesNname) { }

empty($noName);
print_r($noName);
isset($noName);

myFunction($noName);

输出:

PHP Notice:  Undefined variable: noName ... on line 6 // print_r
PHP Notice: Undefined variable: noName ... on line 9 // myFunction

empty()isset() 中使用了 undefined variable 。但是 PHP 没有发布关于它的通知。为什么 PHP 对某些函数显示歧视?我该如何编写此类函数?

最佳答案

isset()empty() 都不是函数。正如手册所述:

this is a language construct and not a function

要获得此行为,您需要调整用 C 编写的 PHP 源代码。

您也可以通过 PHP 扩展获得此行为,但您还需要用 C 语言编写它并将其安装在您的服务器中。

更新:

关于如果变量传递给 empty() 或 isset(),PHP 不会对 undefined variable 发出任何通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13877200/

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