I need an array in multiple pages, so I tried to make a php file where the array is printed. I used:
file_put_contents('file.php',
'<?php $order = ' . var_export($order1, true) . '; ?>');
I was hoping that if I included this file in the files where I need the array, I could use it as $order
, but I get an error instead.
I checked file.php
and everything looks in order.
Does anyone knows what I am doing wrong?
You should not create .php
files by your backend. It is not secure.
I recommend you to use JSON for that:
file_put_contents('file.json',json_encode($order1));
$order = json_decode(file_get_content($url), true);
And you should hide this files from web in your .htaccess or by another available method for secure purpose.