gpt4 book ai didi

ternary-operator - include () 函数的三元运算符错误

转载 作者:行者123 更新时间:2023-12-04 08:35:38 24 4
gpt4 key购买 nike

<分区>

include ( $_GET['p'] == 'home') ? 'pages/home.php' : NULL;

给出错误:

Notice: Undefined index: p in /var/www/index.php on line 38
Warning: require(): Filename cannot be empty in /var/www/index.php on line 38
Fatal error: require(): Failed opening required '' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 38

我理解 undefined index ,但为什么会出现其他错误?这一行:

include ( !isset($_GET['p'])) ? 'pages/home.php': NULL;

工作正常。请注意,第一个代码在 if 语句中可以正常工作(除了我理解的未定义索引)

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