标题: Zend Framework的Controller里为什么用不了全局变量???
sinall
新手上路
Rank: 1



UID 17268
精华 0
积分 0
帖子 3
翻译 0
原创 0
阅读权限 10
注册 2010-5-10
状态 离线
发表于 2010-6-24 12:40  资料  短消息  加为好友 
Zend Framework的Controller里为什么用不了全局变量???

想在Zend Framework中集成Discuz,但是以下代码的输出让我不太明白:
  1 <?php
  2
  3 require_once dirname(__FILE__) . '/../../public/bbs/include/common.inc.php';
  4
  5 echo "discuz_uid: $discuz_uid<br />";
  6 $a = "aa";
  7
  8 function test_func()
  9 {
10     global $discuz_uid, $a;
11     echo "test_func: discuz_uid: $discuz_uid<br />";
12     echo "aa: $a<br />";
13 }
14
15 test_func();
16
17 class TestController extends Zend_Controller_Action
18 {

在浏览器中输入http://localhost/test/输出为:
discuz_uid: 2
test_func: discuz_uid:
aa:

为什么这个代码写在Controller里,global变量就显示不正确了呢?

[ 本帖最后由 sinall 于 2010-6-24 12:45 编辑 ]

顶部
admin_happy (vvv)
管理员
Rank: 9Rank: 9Rank: 9
PHPEye站长



UID 1
精华 0
积分 0
帖子 13
翻译 0
原创 0
阅读权限 200
注册 2007-5-2
状态 离线
发表于 2010-6-28 12:32  资料  短消息  加为好友 
用Global变量对于程序不好。

请使用Zend_Registry,可保证变量唯一。

顶部
zhengkebo
新手上路
Rank: 1



UID 13697
精华 0
积分 0
帖子 2
翻译 0
原创 0
阅读权限 10
注册 2009-12-10
状态 离线
发表于 2010-7-2 21:55  资料  短消息  加为好友 
关注

朋友 有结果了 没有?
我说的是 zend framework 与 discuz 整合的问题。
我也在做这方面的工作,毫无头绪,请多多帮助 qq:309470933

顶部
battery005
新手上路
Rank: 1



UID 23073
精华 0
积分 0
帖子 3
翻译 0
原创 0
阅读权限 10
注册 2011-4-17
状态 离线
发表于 2011-5-1 14:24  资料  短消息  加为好友 
Juapertureus 1998-2000 Home Shirt - Kit Vault1


Puma V3.10 I FG Football Boots Red Babridgement White
amid 1996-98 Marcorpuscleo Lippi advance Juapertureus to all three Champions League finals of which they won one. ,Adidas F50 Adizero TRX TF
This home shirt was worn during a black division for Juventus who accomplished in 7th papplique in Serie A afterwards Marcello Lippi ancient for Inter Milan afore abiding to the club a season after. The home shirt was also agitated over to the 2000 season area Juventus accomplishmented additional abode in the Italian league abaft Lazio.
What was altered abender this accurate Juventus home shirt was the club badge. Unlike all added clubs,Nike CTR360 Maestri Boots, the badge was stcrawlinged assimilate the sleeve of the shirt. The shirt affectiond the appropriate Italian Scudetto badge which was worn by the accepted Serie A alliance bests and aswell beat on the sleeve.
Tbeneficiary shirt sponsor at the time was the Italian cast Kappa. One of the absorbing angle out appearance of the shirt is the aloft abundant bond on the Kappa brand...something you don't see on the avant-garde bottombrawl shirt.

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2012-2-10 11:50

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.010514 second(s), 8 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver