-2

I'm looking to store some basic information (just simple variables, not a database) which doesn't require any security (simple strings stored for case sensitivity, lets me skip a MySQL query to improve performance). I'm looking for quickest way to read the contents and create a few variables from those contents. I'm comfortable with how to interact with flat files for the most part, what I want to do is determine the most efficient way of storing a few variables and interpreting back in to PHP please.

PHP I'll store in the flatfile...

$case = 'My Site Name CaSiNG';
$string2 = 'some text';
1
  • 1
    Make it work. Then make it right. Then make it fast. By that point, you'll have a better idea of what's slowing you down anyway -- and frankly, i doubt it'll be reading "a few variables" no matter how you do it. Commented Jan 4, 2012 at 4:06

1 Answer 1

1

This is fairly fast save for write blocking. I supposed you could also write your variables as strait php which should also be fast

$variables = array();
$variables['case'] = 'My site name';
$variables['string2'] = 'some text';

$write_to_file = serialize($variables);

// todo: save $write_to_file
// todo: open saved file and read contents to $write_to_file

$vars = unserialize($write_to_file);
print_r($vars);

see Convert var_dump of array back to array variable to use var_dump to export all your variables and import them

Sign up to request clarification or add additional context in comments.

1 Comment

I actually just came across serialize and unserialize at php.net. Thanks for actually answering the question and finding a thread where the poster's question was UP voted instead of ridiculed. Both accepted and up-voted.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.