CodeIgniter Forums
How create variable as variable for globel - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: How create variable as variable for globel (/showthread.php?tid=77424)



How create variable as variable for globel - Ashok@in - 08-31-2020

In php 
$id       = 1; //this is changeable 
$var     = 'hello'.$id;
$$var = 'result is here';

echo $$var;   // here var is $hello1
echo $hello1;  // same

works fine in php and codeigniter controller works in  one function only.

1. how to use and update $$var all function with in controller ?

 $$var 
create first function .
update another function .
using another function .

How ??
Thanks.


RE: How create variable as variable for globel - InsiteFX - 08-31-2020

It would help to know where you are setting these are they Global or in a method?


RE: How create variable as variable for globel - Ashok@in - 08-31-2020

(08-31-2020, 04:18 AM)InsiteFX Wrote: It would help to know where you are setting these are they Global or in a method?

var is global
using and changing value of var multiple method func.
within one controller