php类文件如何访问别的文件中的变量 本帖最后由 dz215136304 于 2012-06-04 13:41:29 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 include啊, 怎么获取不到.[User:root Time:13:47:45 Path:/home/liangdong/php]$ php a.php hello php[User:root Time:13:47:48 Path:/home/liangdong/php]$ cat a.php <?phpclass main { public function __toString() { include('b.php'); return $a; }}$main = new main();echo $main;?><?php$a = "hello php";?> 首先类名不能以数字开头。class abc123{ public function index(){ include "index.php"; echo $abc; }}$a=new abc123;$a->index(); 很可能是你的include中的路径不对,这样试试:include(dirname(__FILE__)."/b.php"); 高分求救Regexp函數問題, 急急!!!!! php全局防注射函数 求助:php 如何控制进程? php+jquerymobile 如何实现无刷新添加列表 mysql 查询中文数据 $_POST 取值问题 求解 用过PHP的Discuz!论坛,UCenter Home 和 SupeSite的朋友请进 这个登录处理代码错了,不知道怎么解决! 怎么用open-flash-chart php出横的棒图? 求助~~ PHP怎么修改excel的第二个工作表 Joomla joomla 哪位大哥看一个这两张图片是那种模块 域名解析问题
hello php[User:root Time:13:47:48 Path:/home/liangdong/php]$ cat a.php
<?php
class main {
public function __toString() {
include('b.php');
return $a;
}
}$main = new main();
echo $main;
?><?php
$a = "hello php";
?>
class abc123{
public function index(){
include "index.php";
echo $abc;
}}
$a=new abc123;
$a->index();