Jump to content

Recommended Posts

Posted

Hey guys,

 

I have a probably-silly question, but it's annoying the crap out of me.

 

I'm reading through a config file that has the construct of:

 

      var $lala = "value";
      var $lilili = "second value";

I want to read through this file line by line and output it to a second line with different values.

It's really not a problem, I'm doing it already, my only problem is that whenever I want to read whether or not there's "$lala", the script seems to treat this as the inner VARIABLE $lala instead of just a text string, and since this isn't a variable in my script it returns null.

 

Same happens when I try to output the string, IE I try to write into the new file a *text* line

 

    var $lala = "mynewvalue"; 

The code, again, thinks this means its supposed to search for $lala and output its *value* instead of just printing out the string as is.

 

what do I do? How do I convince PHP to read and write this as a simple text instead of a variable?

 

Here's the code I'm using:

 

   $origFile = "../configuration.php";
   $origFileHandle = fopen($origFile, 'r') or die("Can't Open original configuration.php File");
   $fullFile = Array();
   while (!feof($origFileHandle)) {
       $line = fgets($origFileHandle);
       if (strstr($line,"$host = ")) { $line = '    var $host = '.$dbhost; }
       if (strstr($line,"$user = ")) { $line = '    var $user = '.$Properties[2]['value']; }
       if (strstr($line,"$db = ")) { $line = '    var $db = '.$Properties[1]['value']; }
       if (strstr($line,"$password = ")) { $line = '    var $password = '.$Properties[3]['value']; }
       if (strstr($line,"$sitename = ")>0) { $line = '    var $sitename = '.$Properties[4]['value']; }
   }
   fclose($origFileHandle);

Posted

I knewwwww it was a stupid thing I forgot.

 

Bah! :D

 

Thanks!

 

BTW... that reminds me -- is this also the difference between "echo" and "print" ? and if not, uh, what is the difference? anyone knows?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.