LostKobrakai Posted July 3, 2014 Posted July 3, 2014 Hi there, is this a behavior of "$session->data" a lack of my php knowledge or is this a bug, that empty() returns false? var_dump($session->successmsg); var_dump(!empty("Erfolgreich! Ihnen wurde eine Email mit den Download links zugeschickt.;")); var_dump(!empty($session->successmsg)); $tmp = $session->successmsg; var_dump(!empty($tmp)); Output: string(72) "Erfolgreich! Ihnen wurde eine Email mit den Download links zugeschickt.;" bool(true) bool(false) bool(true) Greetings, Benjamin
Soma Posted July 3, 2014 Posted July 3, 2014 $sesion is a wrapper for the native session. One of the good things is you don't need to do isset($session->data) but just if($session->data) ... If it doesn't exists or is empty it will return NULL. 1
LostKobrakai Posted July 3, 2014 Author Posted July 3, 2014 So it was my lack of php knowledge . I set it to "" at the beginning of my formvalidation and I thought it would be nicer to read this way, instead of "if($session->data != "")"
WillyC Posted July 3, 2014 Posted July 3, 2014 empty need.real variabble nots one come.from no public objecto.proptery empty not triggers__get or __call in objectos.stop using it u will 4
Wanze Posted July 3, 2014 Posted July 3, 2014 WillyC is right Another example that does not work with magic getters: $arr = array(1,2,3); $session->arr = $arr; // Does not work! echo $session->arr[1]; // To echo out array elements, do this $arr = $session->arr; echo $arr[1]; 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now