Jump to content

best way to store a short bit of information


Jocka

Recommended Posts

I haven't really messed with PHP in like 2 years. Just little fixes on old scripts every now and then. I've been kind of in an argument with myself the past couple of days while writing a script.

 

The thing is I only have around 3 or 4 sets of information I need. Such as:

 

option1: information for option 1
option2: information for option 2
option3: information for option 3
etc..

 

NOW, at first I was doing this all in a text file. This information doesn't necessarily need to be private but i also don't want people to know what file needs to be edited right off the bat.

 

I don't see any reason at all for using databases here, I'd much rather stick to files.

 

I'm thinking it may be best to store this is strings in a seperate PHP file and include it? Then if I need to edit it, I can simply write a new file.

 

Any suggestions?

As it goes right now I have 2 basic files: ((edited, sorry my original file was ridiculous))

 

THE FILE THAT READS/WRITES THE INFO

<?php
// &#36; = $

$content = "<?php

&#36;info1 = \"new info\";
&#36;info2 = \"new info 2\";
&#36;info3 = \"new info 3\";

?>";

$handle = fopen('info_holder.php', 'w+');

fwrite($handle, html_entity_decode($content));
fclose($handle);

include ('info_holder.php');
echo $info1;

?>

 

THE FILE THAT HOLDS THE INFO

<?php

$info1 = "info number 1";
$info2 = "info number 2";
$info3 = "info number 3";

?>

 

Any other ideas for this small ideas on a better way would be nice. Otherwise I'll stick with this little script idea for now.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.