No puedo acceder a variables de objetos en PHP

For some reason when I print_r a variable containing an object I get data. However when I try to access each item using the -> notation it says it is NULL.

Aquí está la print_r dump of $user_data:

    [UACC_ID] => 6 
    [UACC_GROUP_FK] => 1 
    [UACC_EMAIL] => xxx@GMAIL.COM 
    [UACC_USERNAME] => xxxx 
    [UACC_PASSWORD] => $2A$08$CLSxxxxxxEOS7D2NDCSDD3P6A6 
    [UACC_FORGOTTEN_PASSWORD_EXPIRE] => 0000-00-00 00:00:00 
    [UACC_ACTIVE] => 1 
    [UACC_SUSPEND] => 0 
    [UACC_DATE_FAIL_LOGIN_BAN] => 0000-00-00 00:00:00 
    [UACC_DATE_LAST_LOGIN] => 2013-05-05 07:18:34 
    [UACC_DATE_ADDED] => 2013-04-28 09:34:39 
    [UGRP_ID] => 1 
    [UGRP_ADMIN] => 0 
    [UPRO_ID] => 6 
    [UPRO_UACC_FK] => 6 
    [UPRO_COMPANY] => 
    [UPRO_FIRST_NAME] => xxxx 
    [UPRO_LAST_NAME] => xxxxx 
    [UPRO_PHONE] => 01392 
    [UADD_ID] => 
    [UADD_UACC_FK] => 
    [UADD_ALIAS] => 
    [UADD_PHONE] => 
    [UADD_COMPANY] => 
    [UADD_ADDRESS_01] => 
    [UADD_ADDRESS_02] => 
    [UADD_CITY] => 
    [UADD_COUNTY] => 
    [UADD_POST_CODE] => 
    [UADD_COUNTRY] => 

However, when I try this I get NULL:


I can't seem to echo anything by using the notation $user_data->UACC_EMAIL etc. ¿Qué estoy haciendo mal?

Thank you all. It appears the output was being converted to ALLCAPS in CSS and so I didn't realise that the library actually uses the lower case variants.


preguntado el 05 de mayo de 13 a las 14:05

If there wasn't such key as UACC_ID you will get an error trying to access $user_data->UACC_ID - that means that something maybe override the value - can you post the full code ? -

The only code I have is the below, I don't understand why it doesn't work: $user_data = $this->flexi_auth->get_user_by_id()->row(); print_r($user_data); //var_dump($user_data); var_dump($user_data->UACC_ID); -

Ninguno print_r ni var_dump turn output to ALLCAPS, post the actual output without embellishing it. Edit: since you're using Flexi Auth, the column is named uacc_idno, UACC_ID. -

DCoder is completely right - are you seguro no es $user_data->uacc_id or $user_data->uacc_ID etc., and you either have a CSS transform or turn it all into uppercase using an output buffer and strtoupper? -

1 Respuestas

One possibilities, however strange, is that the object has a __get function defined to capture and return null on internal private data points, to prevent php from throwing fatal "cant access private" errors if you try accessing any data directly.

so, yes, UACC_ID exists, and is in there, but is being intercepted.

contestado el 05 de mayo de 13 a las 14:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.