Php Can';不要在Judy中插入任何值

Php Can';不要在Judy中插入任何值,php,arrays,php-extension,Php,Arrays,Php Extension,我对Judy Array的行为很奇怪。文档只是说您可以像使用普通PHP数组一样使用它。但无论我做什么,在我看来它都不会存储任何信息 例如,如果我这样做: $this->_history = new Judy(Judy::STRING_TO_MIXED); $this->_history['test'] = 'testString'; echo $this->_history['test']; // output nothing; no warnings no text noth

我对Judy Array的行为很奇怪。文档只是说您可以像使用普通PHP数组一样使用它。但无论我做什么,在我看来它都不会存储任何信息

例如,如果我这样做:

$this->_history = new Judy(Judy::STRING_TO_MIXED);
$this->_history['test'] = 'testString';
echo $this->_history['test']; // output nothing; no warnings no text nothing
var_dump($this->_history); // class Judy#126 (0) { }
$this->_history->getType() // correctly (int) 5
$this->_history->getTypeFoo() // warning no method
我做错什么了吗?我忘了什么吗?我在Ubuntu和Debian系统上测试了它,两者都是一样的

同样有趣的是,当我运行
pecl
包中提供的bench脚本并在
/usr/share/php/doc/Judy/examples/Judy-bench-string_to_int.php
下提取时,Judy数组工作正常

我是这样安装的:

sudo aptitude install libjudydebian1 libjudy-dev
sudo pecl install judy
它说安装成功了,我把
extension=judy.so
添加到
php.ini


我该怎么做才能让朱迪工作呢?

好了,现在可以了。但实际上我不知道为什么。我不在乎。 我将
/docs
文件中的
bench-*.php
文件中的工作代码复制到我自己的文件中,并且工作正常。代码如下:

echo "\n-- Judy STRING_TO_INT \n";
echo "Mem usage: ". memory_get_usage() . "\n";
echo "Mem real: ". memory_get_usage(true) . "\n";

$s=microtime(true);
$judy = new Judy(Judy::STRING_TO_MIXED);
for ($i=0; $i<500; $i++)
    $judy["$i"] = 'test';
var_dump($judy);
unset($judy["102"]);
echo $judy["192"];
var_dump($judy["102"]);
echo "Size: ".$judy->size()."\n";
$e=microtime(true);
echo "Elapsed time: ".($e - $s)." sec.\n";
echo "Mem usage: ". memory_get_usage() . "\n";
echo "Mem real: ". memory_get_usage(true) . "\n";
echo "\n";

unset($judy);
echo“\n--Judy STRING\u TO\u INT\n”;
echo“Mem用法:”。内存使用率()。“\n”;
回声“memreal:”。内存使用率(true)。“\n”;
$s=微时间(真);
$judy=新judy(judy::STRING\u TO\u MIXED);
对于($i=0;$isize()。“\n”;
$e=微时间(真);
回显“已用时间:”($e-$s)。“秒。\n”;
回显“Mem用法:”.memory\u get\u usage()。“\n”;
echo“Mem real:”.memory\u get\u usage(true)。“\n”;
回音“\n”;
unset($judy);

现在可以了。但实际上我不知道为什么。我不应该在意。 我将
/docs
中的
bench-*.php
文件中的工作代码复制到我自己的文件中,并成功运行。以下是代码:

echo "\n-- Judy STRING_TO_INT \n";
echo "Mem usage: ". memory_get_usage() . "\n";
echo "Mem real: ". memory_get_usage(true) . "\n";

$s=microtime(true);
$judy = new Judy(Judy::STRING_TO_MIXED);
for ($i=0; $i<500; $i++)
    $judy["$i"] = 'test';
var_dump($judy);
unset($judy["102"]);
echo $judy["192"];
var_dump($judy["102"]);
echo "Size: ".$judy->size()."\n";
$e=microtime(true);
echo "Elapsed time: ".($e - $s)." sec.\n";
echo "Mem usage: ". memory_get_usage() . "\n";
echo "Mem real: ". memory_get_usage(true) . "\n";
echo "\n";

unset($judy);
echo“\n--Judy STRING\u TO\u INT\n”;
回显“Mem用法:”.memory\u get\u usage()。“\n”;
echo“Mem real:”.memory\u get\u usage(true)。“\n”;
$s=微时间(真);
$judy=新judy(judy::STRING\u TO\u MIXED);
对于($i=0;$isize()。“\n”;
$e=微时间(真);
回显“已用时间:”($e-$s)。“秒。\n”;
回显“Mem用法:”.memory\u get\u usage()。“\n”;
echo“Mem real:”.memory\u get\u usage(true)。“\n”;
回音“\n”;
unset($judy);

尝试
{$this->\u history}['test']
进行分组。是否在对象方法中运行此操作?
$this
将不存在,除非您实际在实例化对象中。是的,我在类方法中运行此操作。如果执行
{$this->\u history}['test']
操作,我将得到意外的“}”错误。您确定PHP配置中设置的错误报告会在屏幕上显示警告和通知吗?请尝试
{$this->\u history}['test']
用于分组。是否在对象方法中运行此操作?
$this
将不存在,除非您实际在实例化对象中。是的,我在类方法中运行此操作。如果我在
{$this->\u history}['test']
中运行此操作,我将得到意外的“}”错误。您确定PHP配置中设置的错误报告会在屏幕上显示警告和通知吗?