错误提示:尝试在zend框架中获取非对象的属性

时间:2012-02-21 02:52:17

标签: php zend-framework

我使用charset utf 8,这是错误的:

Notice: Trying to get property of non-object in C:\wamp\www\zend-search-lucene\indexing.php on line 27

这是代码php:

<?php
require_once 'Zend/Search/Lucene.php';
$arr_data = array(0 => array(    "products"       => "Google suggest : pick right search keyword"),
                      1 => array("products"       => "zend framework tutorial | part 9 Zend Auth"));

$lucene_index_path = 'data/';
$index = new Zend_Search_Lucene($lucene_index_path, true);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());

foreach($arr_data as $test) {
    //create an cache index doc
    $doc = new Zend_Search_Lucene_Document();
    $doc->addField(Zend_Search_Lucene_Field::Text('products', $test->products, 'UTF-8')); **//LINE 27**
    $index->addDocument($doc);
}
$index->commit();
$index->optimize();

1 个答案:

答案 0 :(得分:3)

$doc->addField(Zend_Search_Lucene_Field::Text('products', $test['products'], 'UTF-8'));

$test->products更改为$test['products']