Welcome Guest [Log In] [Register]
Add Reply
Writing to predetermined position in file; PHP
Topic Started: Apr 5 2009, 03:54 PM (274 Views)
GhettoFish
Member Avatar
Awesomeness FTW!
Hey.

I am trying to set up an installation file for my cixzBB forum but I have some trouble with figuring out how to do this the best way.
One way to do this would be to create and write the entire file during the installation. But this seems like a bad way to do it.

What I am doing now is to use fopen to create/open file and fwrite to write to file.
Now I have this huge array with all the file data and insert the variables in the correct positions in the array.
This is definetly one way to do it... If I got it to work that is :P

What I would like to do is to set up the file like this first.

Code:
 
<?php

$db_psw = "";
$db_usr = "";
$db_name = "";

etc...
?>


And then insert the variables into the blank "".
So, anyone got any ideas?
I'm not young enough to know everything.
- J.M. Barrie
http://www.cixz.org/
Offline Profile Quote Post Goto Top
 
Darksorrow131

You can put something random, like $db_psw = "INSERT DB_PSW HERE";
and then read the file, string-replace it with whatever you have, and re-write.

Another approach is to simply avoid code generation somehow (not something PHP is good at), and programmatically set the value of $db_psw. Might not work in your case though.
(let loop () (loop))
((lambda (x) (x x)) (lambda (x) (x x)))
(let ((k #f)) (call/cc (lambda (cc) (set! k cc)) (k))
((call/cc call/cc) (call/cc call/cc))

-- Infinite loops are awesome! --
Tell me if you have other awesome infinite loops!
Offline Profile Quote Post Goto Top
 
GhettoFish
Member Avatar
Awesomeness FTW!
I didn't get what you meant by "avoid code generation" but the first alternative with string-replace sounds like a good approach. I will look in to that.

Thanks a lot mate!
I'm not young enough to know everything.
- J.M. Barrie
http://www.cixz.org/
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Web-Based Programming Support · Next Topic »
Add Reply

Banner and Logo by TheKeith