Extract array variable |
Hi
I have array that i need to extract it in my file and use it I extract array in file1.php and need to use file2.php also But file2.php cannot find it I can use extract array in files2.php but it is good if i can use in file1.php Thanks PHP Code: extract(array('title' => 'hello'));
(02-28-2020, 03:38 AM)wdeda Wrote: It's a PHP question:I know and know how do work extract function Only i need extract array and use multi files
Forget about extract - it is just a function. You have a variable, say $foo. How wouuld you make it accessible for different files? You need to store variable somewhere: in a Session for example, or in the Database. You can also use a Class as your Data Transfer Object, or just call global function defined in file1, that is included or required by file2.
Many options, but none of them are related to CI, but rather to general ability to code and your app architecture.
(02-28-2020, 05:10 AM)zahhar Wrote: Forget about extract - it is just a function. You have a variable, say $foo. How wouuld you make it accessible for different files? You need to store variable somewhere: in a Session for example, or in the Database. You can also use a Class as your Data Transfer Object, or just call global function defined in file1, that is included or required by file2. Thank you zahhar I hold data in flash session and get it in other page and extract it I could extract only in page that i need But i like use extracted variables in all pages Thanks
Well, if you already know how to use flashdata, you may reuse same concept and utilize Session class for data persistancy between requests: https://codeigniter4.github.io/userguide...sions.html
In file1.php PHP Code: $session = \Config\Services::session(); In file2.php PHP Code: $session = \Config\Services::session();
(02-28-2020, 09:22 AM)zahhar Wrote: Well, if you already know how to use flashdata, you may reuse same concept and utilize Session class for data persistancy between requests: https://codeigniter4.github.io/userguide...sions.htmlThanks |
Welcome Guest, Not a member yet? Register Sign In |