源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

解析thinkphp import 文件内容变量失效的问题

  • 时间:2021-04-28 17:31 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:解析thinkphp import 文件内容变量失效的问题
用TP 集成支付宝账户绑定功能时碰上个问题 ORM 下有文件 config.class.php 直接import()后 发现里面的变量无法使用  但确实是加载咯。。(在config.class.php输出内容成功) 思考百度了半天。。 原来一直知道 JS 作用域 忽略了 PHP 函数也有作用域的- - [b]具体原理: [/b]
[u]复制代码[/u] 代码如下:
<?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";    } } ?>
[b]显示: [/b][img]http://files.jb51.net/file_images/article/201306/2013062016090812.png[/img]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部