这行怎么起作用:require_once('Zend / Registry.php');?

时间:2013-04-18 05:54:58

标签: php zend-framework2

我在win 7上安装了Zend Framework 2(Zend Framework + Zend Server)。 在Zend/Apache2/htdocs/hello1.php中,我将脚本放在下面:

<?php
    require_once('Zend/Registry.php'); 
    $registry = Zend_Registry::getInstance(); 
    $registry['name'] = 'Quentin Zervaas'; 
    echo sprintf('My name is %s', $registry['name']);
?>

然后我运行http://localhost/hello1.php,它显示: 我的名字是Quentin Zervaas

我的问题是: 对于htdocs文件夹下的这一行require_once('Zend/Registry.php');,它是dummy.php,favicon.ico,index.html,hello1.php, 没有Zend文件夹,那么这行如何运作?

2 个答案:

答案 0 :(得分:4)

在你的php.ini中检查这个

include_path 

它将具有zend目录的默认位置。

答案 1 :(得分:0)

如果您使用的是Zend Framework 2 - 您不应该使用Zend_Registry。这是ZF 1组件而不是ZF 2组件。它工作的唯一原因是因为你的包含路径和Zend Server将ZF 1放在那里。