Read and Write to php file

I am looking for a method to write the values of some variable to a PHP file.

Ok let me explain by example:

I have a normal PHP website and want to add WordPress as a blog to it.

I use the same theme as of my WordPress for the other site too, removing the WordPress tags and replacing them with my other application’s tags. So here the Div IDs and Class names remain the same. Also I share the same CSS & JS files as WordPress.

I want to control the width of my sidebars and some other parameters from the WordPress Theme control panel. The process I think should be…

get value for 'sidebar_a' and say inputs is '150px' get value for 'main_body' and say inputs is '550px' get value for 'sidebar_b' and say inputs is '200px' get value for ‘site_name’ and say the input comes from the WordPress tag get value for ‘footer ‘and say again the value comes from the WordPress footer.

Now I need a small script which will write these values in a PHP file like:

$sidebar_a = '100'

$main_body = '550'

$sidebar_b = '200'

$sitename = ‘XYZ Corporation’

$footer = ‘Copyright XYZ corporation'

or better create some database tables in MySQL and write to it.

I would then want to call this file in my application 2 using

Please feel free to suggest, if there is a better way.

IMPORTANT: Every time these parameters are changed in WordPress, these values must be updated with the new values.

Kindly help.


Write data

$data = array(
    'sidebar_a' => $sidebar_a,
    'main_body' => $main_body,
    'sidebar_b' => $sidebar_b,
    'sitename' => $sitename,
    'footer' => $footer
$data = serialize($data);
file_put_contents('file.txt', $data);

Read data

$data = file_get_contents('file.txt');
$data = unserialize($data);

See serialize and extract

Need Your Help

Excel VBA - Saving file changes date format

excel vba date excel-vba

I am trying to automate a process we have to be as smooth as possible by using a macro in Excel to drag formulae down as far as my master data needs, then saving each sheet as a prn file.

Incorporating sheet loop

excel vba excel-vba

Hi there i have this code which only runs on a single sheet(sheet3) but i want it to loop through other sheets of the workbook and run this code. I tried using the for each loop but it does not see...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.