<?php
global $vfp_oledb_CString;
$vfp_oledb_CString="Provider=VFPOLEDB.1;Data Source=d:/testoledb; Collating Sequence=MACHINE";
testgol();
function testgol(){
echo $vfp_oledb_CString;
}
结果是没有任何输出, 应该如何定义和使用全局变量呢
PHP
全局变量
------解决方案--------------------
$vfp_oledb_CString="Provider=VFPOLEDB.1;Data Source=d:/testoledb; Collating Sequence=MACHINE";
testgol();
function testgol(){
global $vfp_oledb_CString;
echo $vfp_oledb_CString;
}
------解决方案--------------------
也可以用$GLOBAL超全局变量
$vfp_oledb_CString="Provider=VFPOLEDB.1;Data Source=d:/testoledb; Collating Sequence=MACHINE";
testgol();
function testgol(){
echo $GLOBALS['vfp_oledb_CString'];
}