【发布时间】:2014-09-05 17:19:29
【问题描述】:
我有以下代码:
<?php
session_start();
require_once('ClassFile.php');
use ClassFile\Component;
include 'somefile.php';
?>
在这个模板中,我可以访问组件的属性(例如 $comp = new Component();)。但是,组件在 somefile.php 中是不可见的。我收到一个错误,大意是它不存在。 (糟糕的)解决方法是在 somefile.php 中复制相同的代码。任何人都可以说发生了什么事吗?我是否需要以某种方式全球化 require_once 和 use 语句中的项目?谢谢。
【问题讨论】:
-
somefile.php中有什么不起作用?
标签: php variables scope include