欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解析thinkphp import 文件內(nèi)容變量失效的問題

 更新時間:2013年06月20日 16:14:44   作者:  
本篇文章是對thinkphp import文件內(nèi)容變量失效的問題進行了詳細的分析介紹,需要的朋友參考下
用TP 集成支付寶賬戶綁定功能時碰上個問題
ORM 下有文件 config.class.php
直接import()后 發(fā)現(xiàn)里面的變量無法使用  但確實是加載咯。。(在config.class.php輸出內(nèi)容成功)
思考百度了半天。。
原來一直知道 JS 作用域 忽略了 PHP 函數(shù)也有作用域的- -
具體原理:
復(fù)制代碼 代碼如下:

<?php
class b{
   function test(){
      myImport("a.php");
      $testClass = new impClass();
      $testClass->test();
      echo $a."from b";
   }
}
class a{
   function funa(){
      $InsB = new b();
      $InsB->test();
   }
}
function myImport($file){
   require $file;
   echo $a."from myImport";
}
$InsA = new a();
$InsA->funa();
?>
a.php
<?php
$a = "a";
class impClass{
   function test(){
      echo "import success";
   }
}
?>

顯示:

相關(guān)文章

最新評論