<h1><?php echo $GLOBALS['translate']['About'] ?></h1>
Notice: Undefined index: About in page.html on line 19
是否可以“捕获”一个 undefined index 以便我可以创建它(数据库查找)并从我的函数中返回它然后执行回显?
最佳答案
检查值是否已分配的最简单方法是使用 isset 方法:
if(!isset($GLOBALS['translate']['About'])) {
$GLOBALS['translate']['About'] = "Assigned";
}
echo $GLOBALS['translate']['About'];
关于php - 捕获数组中 undefined index 并创建它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3298381/