php将参数传递给方法

时间:2013-05-23 15:38:02

标签: php methods arguments

我有以下代码:

$o_search = new ObjectSearch();
$o_search -> user = $user;
$o_search -> date =':"2012"';
$o_search -> chtype = 'created';
echo "Changetype: " . $o_search -> chtype . "<br/>\n";
echo "User: " .  $o_search -> user . "<br/>\n" ;
echo "Date: " . $o_search -> date  . "<br/>\n"  ;
$result = $o_search->search($o_search->chtype , $o_search->user , $o_search->date);

最后一行是我遇到麻烦的地方。什么是正确的语法将这些参数传递给'search'方法?如果我用有效的字符串替换这些参数,代码就可以了。 接下来是objectSearch类:

include_once(__CA_LIB_DIR__."/ca/Search/BaseSearch.php");
include_once(__CA_LIB_DIR__."/ca/Search/ObjectSearchResult.php");

class ObjectSearch extends BaseSearch {
        # ----------------------------------------------------------------------
        /**
         * Which table does this class represent?
         */
        protected $ops_tablename = "ca_objects";
        protected $ops_primary_key = "object_id";
        # ----------------------------------------------------------------------
        public function &search($ps_search, $pa_options=null) {
                return parent::doSearch($ps_search, new ObjectSearchResult(), $pa_options);
        }
        # ----------------------------------------------------------------------
}

提前致谢。

1 个答案:

答案 0 :(得分:0)

嗯,这很令人尴尬,就像输入它一样简单......

$ result = $ o_search-&gt; search($ o_search-&gt; chtype。“。”。$ o_search-&gt; user。'。:“'。$ o_search-&gt; date。'”'); < / p>

我必须在正确的位置添加标点符号。 希望这有助于某人。