Re: un include?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Copying back to the list where it belongs...

On Sunday 11 February 2007 11:01 am, jekillen wrote:
> On Feb 10, 2007, at 8:58 PM, Larry Garfield wrote:
> > You need to rearchitect your system.
> >
> > When you include a file, its code executes.  Once it has been
> > executed, it is
> > done.  It will never "rewind" itself.  You can open and edit the file,
> > but
> > the code has already executed and that execution has happened, and you
> > cannot
> > change that.
> >
> > What exactly are you trying to accomplish?  Dollars to donuts there's
> > a much
> > easier and more logical way than trying to edit an included file.
>
> Thanks for the reply. It is good to understand what you are telling me
> here.
> I was concerned that the file would not be accessible by a call to
> fopen when
> it has been included. It is just a series of configuration variables
> that are set
> and I want the user to be able to change one of these variables' values.
> What turned up was that I was referencing the variable by the wrong
> name in a str_replace call.
> thanks again
> JK

You're using str_replace() on PHP code to control configuration variables?  
There's a half dozen better ways that are less error prone and faster and 
more secure.

My recommendation:

- If the config is all simple values, use an ini file.  You can then use 
parse_ini_file() to read the data into an array that you can reference, and 
can write the array back out easily.  (Ini is a very simple format.)

- If you want it to be programmatically editable, put it in your database and 
be done with it.  A simple key/value table with a getter function and setter 
function is trivial to setup, but far more robust and flexible than messing 
around with the file system.

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux