Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试在php中调用函数内部的变量_Php_Database_Global Variables - Fatal编程技术网

尝试在php中调用函数内部的变量

尝试在php中调用函数内部的变量,php,database,global-variables,Php,Database,Global Variables,我想编程一个函数,根据输入显示数据库的元素 这是我的代码,但第34行有个错误 注意:未定义索引:中的表[1][“des_dem”] 第34行的C:\xampp\htdocs\gpc\test.php 名称 非常感谢您回答我的问题:)您必须使用global关键字来执行此操作,您不能在$GLOBALS数组中这样调用它,请执行此操作 function afficher() { global $table; echo $table[0][1]; } 这应该是:echo$G

我想编程一个函数,根据输入显示数据库的元素

这是我的代码,但第34行有个错误

注意:未定义索引:中的表[1][“des_dem”] 第34行的C:\xampp\htdocs\gpc\test.php



名称

非常感谢您回答我的问题:)

您必须使用
global
关键字来执行此操作,您不能在$GLOBALS数组中这样调用它,请执行此操作

function afficher()
 {
     global $table;
     echo $table[0][1];
 }

这应该是:
echo$GLOBALS[$table[1][“des_dem”]
function afficher()
 {
     global $table;
     echo $table[0][1];
 }