Hi there I have tried to find answers to my problems via stackoverflow but it seems that I can not find anything It is my problem, I am currently using an MVC framework and I need to access a variable from a model on my controller. This is my model:
& lt ;? Php use ghazal \ hpp \ customer; Class status_model CI_Model {public function get_location ($ location) {// Create client and provide original url $ client = new client ('http://maps.googleapis.com/maps/api/geocode/json'); $ Request = $ client- & gt; Receive ('? Address ='. $ Location. 'And sensor = false'); // Submit Request and Receive Feedback $ response = $ request- & gt; Send (); // decode json file to get latitude and latitude $ json = json_decode ($ response-> getBody ()); Var_dump ($ json); ($ Json ["results"] [0] ["formatted_address"] and $ json ["result"] [0] ["geometry"] ["viewport"] ["northeast"]) {$ position ["address "] = $ Js [[" result "] [0] [" formatted_address "]; $ Position ["latitude"] = $ JSON ["result"] [0] ["geometry"] ["viewport"] ["northeast"] ["latitude]]; $ position [" longitude "] = $ json [ "Result"] [0] ["geometry"] ["viewport"] ["northeast"] ["lng"]; return status; $ code = 'success'; $ content =' found location ... i'm terrible Am '; $ this-> output-> set_status_header (201);} and {$ code =' error '; $ content =' opspace location not found '; $ this-> gtc- gt; & gt; output- & gt; Set_status_header (400);}} }
} I need to get the status outside this class It is used which is used in a controller while determining it and it is added to me with another variable called $ data:
$ position = $ this- & gt; Status_model- & gt; get_location ($ location) - & gt; position; $ data + $ location; please help me !!!! However apparently, this does not work And gives me an error like this: Calling undefined status or non-object property
Get_location is you -> Status is not required Your code should be
$ position = $ this- & gt; Status_model- & gt; Get_location ($ location); $ Data + = $ location; The error is telling you that you are trying for a treatment that is not like any object.
No comments:
Post a Comment