名称间隔和APC失败


Namespacing and APC fails

我正在尝试将APC与PHP一起使用。我已经从PHP手册中复制了用于在APC中存储数组的代码;正如我所期望的那样,它工作得很好。

当我在命名空间失败时引入它时,我的问题就出现了。

<?php
namespace tester;
$objs = array();
$objs[] = "123";
$objs[] = "123";
$objs[] = "123";
apc_store('tester:objs', new ArrayObject($objs),60);
$tmp = apc_fetch('tester:objs');
print_r($tmp -> getArrayCopy());
exit;

啊hhhh!我就知道会很简单!我只是忘记了将ArrayObject声明为全局命名空间类。在ArrayObject前面添加斜线成功。真傻!:(

工作代码:

<?php
namespace tester;
$objs = array();
$objs[] = "123";
$objs[] = "123";
$objs[] = "123";
apc_store('tester:objs', new 'ArrayObject($objs),60);
$tmp = apc_fetch('tester:objs');
print_r($tmp -> getArrayCopy());
exit;