php - how can I make an object from string contains printed object -


i have code:

test controller:

        class test extends ci_controller{             public function print_object(){                  $x = (object) array('a'=>'a', 'b'=>'b', 'c');                  echo '<pre>'.print_r($x, true).'</pre>';             }         } 

test2 controller:

        class test2 extends ci_controller{             public function get_printed_object(){                  $url = "http://localhost/project/test/print_object";                  (object) $str = file_get_contents($url);                  echo $str->a; //won't make it. resulting error             }         } 

the line

echo $str->a; 

was resulted warning : trying property of non-object

is possible me re-make $x object printed string?

the main issue have file_get_contents returns string output of url. $str therefore string , cast won't change that.

if want convert object can json_encode (or serialize) , output in test. test2 have json_decode($str) recreate object.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -