0

我一直在努力解决这个问题,包括在这里查看问题(例如这个问题:Read var_dump data with PHP),但我就是不明白。

我正在尝试检索以下值:

COM_USERS_REGISTRATION_SAVE_FAILED

并将其存储为变量。这是我试图从中检索它的绝对混乱(我不明白)(这是文本的最后一行):

object(UsersModelRegistration)#98 (9)
    { ["data:protected"]=> object(stdClass)#106 (1) { 
        ["groups"]=> array(1) {
            [0]=> string(1) "2" } }         
    ["_forms:protected"]=> array(0) { }
    ["__state_set:protected"]=> NULL
    ["_db:protected"]=> object(JDatabaseMySQL)#15 (19) {
        ["name"]=> string(5) "mysql"
        ["nameQuote:protected"]=> string(1) "`"
        ["nullDate:protected"]=> string(19) "0000-00-00 00:00:00"
        ["dbMinimum:protected"]=> string(5) "5.0.4"
        ["_database:private"]=> string(15) "table_joomla"
        ["connection:protected"]=> resource(29) of type (mysql link)
        ["count:protected"]=> int(0)
        ["cursor:protected"]=> resource(83) of type (Unknown)
        ["debug:protected"]=> bool(false)
        ["limit:protected"]=> int(0)
        ["log:protected"]=> array(0) { }
        ["offset:protected"]=> int(0)
        ["sql:protected"]=> object(JDatabaseQueryMySQL)#126 (18) {
            ["db:protected"]=> *RECURSION*
            ["type:protected"]=> string(6) "select"
            ["element:protected"]=> NULL
            ["select:protected"]=> object(JDatabaseQueryElement)#127 (3) {
                ["name:protected"]=> string(6) "SELECT"
                ["elements:protected"]=> array(1) {[0]=> string(4) "`id`" }
                ["glue:protected"]=> string(1) "," }
            ["delete:protected"]=> NULL
            ["update:protected"]=> NULL
            ["insert:protected"]=> NULL
            ["from:protected"]=> object(JDatabaseQueryElement)#128 (3) {
                ["name:protected"]=> string(4) "FROM"
                ["elements:protected"]=> array(1) {
                    [0]=> string(10) "`#__users`" }
            ["glue:protected"]=> string(1) "," }
            ["join:protected"]=> NULL
            ["set:protected"]=> NULL
            ["where:protected"]=> object(JDatabaseQueryElement)#129 (3) {
                ["name:protected"]=> string(5) "WHERE"
                ["elements:protected"]=> array(2) {
                    [0]=> string(31) "`username` = 'test123@mail.com'"
                    [1]=> string(9) "`id` != 0" }
            ["glue:protected"]=> string(5) " AND " }
            ["group:protected"]=> NULL ["having:protected"]=> NULL
            ["columns:protected"]=> NULL ["values:protected"]=> NULL
            ["order:protected"]=> NULL ["union:protected"]=> NULL
        ["autoIncrementField:protected"]=> NULL }
        ["tablePrefix:protected"]=> string(6) "s7kou_"
        ["utf:protected"]=> bool(true)
        ["errorNum:protected"]=> int(0)
        ["errorMsg:protected"]=> string(0) ""
        ["hasQuoted:protected"]=> bool(false)
    ["quoted:protected"]=> array(0) { } }
    ["name:protected"]=> string(12) "registration"
    ["option:protected"]=> string(9) "com_users"
    ["state:protected"]=> object(JObject)#99 (1) {
        ["_errors:protected"]=> array(0) { } }
    ["event_clean_cache:protected"]=> string(19) "onContentCleanCache"
    ["_errors:protected"]=> array(1) {
        [0]=> string(34) "COM_USERS_REGISTRATION_SAVE_FAILED" } }
4

2 回答 2

0

对象的所有属性都受到保护,要访问它们,您应该在 UsersModelRegistration 类中实现“getter”/或扩展 UsersModelRegistration 并实现 getter

/**
* @returns array
*/
public function getErrors(){

return $this->_errors;
}
于 2013-02-07T07:41:09.850 回答
0

看看类源,很可能有一个方法可以返回这个值。有一些解决方案可以访问受保护的属性(反射或将对象转换为数组),但我不会推荐这些,因为它们完全违反了 OOP 的封装原则。该属性受到保护是有原因的,您应该通过UserModelRegistration.

于 2013-02-07T07:53:41.477 回答