mem0ri Posted March 13, 2008 Share Posted March 13, 2008 Server: PHP 5.2.0 Class runs without error. Page runs without error. When I try to reference -any- variable acquired through the __get function, however, the page fails and load stops. reference in page: $data = new ReceiveComms; //takes $_GET and $_POST and $_HEADER variables and places them in arrays. echo $data->obj; Class function: public function __get($property) { if(array_key_exists($property, $this->headers)) return $this->headers($property); else if(array_key_exists($property, $this->data)) return $this->data($property); else return NULL; } Interesting thing is...if I print_r either $this->headers or $this->data, they have all of the appropriate values...and $this->data has the 'obj' key... ...anyone else experience similar problems? Any solutions? Quote Link to comment Share on other sites More sharing options...
Stooney Posted March 13, 2008 Share Posted March 13, 2008 I believe you need the parenthesis when creating a new object: (I could be wrong) $data = new ReceiveComms(); Quote Link to comment Share on other sites More sharing options...
keeB Posted March 13, 2008 Share Posted March 13, 2008 I believe you need the parenthesis when creating a new object: (I could be wrong) $data = new ReceiveComms(); You are wrong. To the op: You didn't provide much data. __get is not something I work with, though. It's being extremely lazy. Opening up your entire for get/set is bound to cause way too much of a headache down the line. Quote Link to comment Share on other sites More sharing options...
mem0ri Posted March 14, 2008 Author Share Posted March 14, 2008 Thanks to both posters... ...no, a new object does not need parentheses... ...I also agree that opening up an entire __get and __set can be messy...but I did so on this class because it exists purely for the purpose of taking received variables, manipulating them, and then placing them into the only class-global variables that exist for the express purpose of getting and setting those array values within the page. The problem was actually... if(array_key_exists($property, $this->headers)) return $this->headers($property); needed to be if(array_key_exists($property, $this->headers)) return $this->headers[$property]; Talk about a headache over nothing...just found that after leaving the project and coming back and scratching my head a bit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.