Page 1 of 1
String Replace
Posted: Sun Jan 21, 2007 10:15 am
by iknownothing
Hello All,
I was wondering if it were at all possible to replace a certain character throughout an entire include file...
something like this?
Code: Select all
$change = str_replace("hello", "goodbye", include("hellogoodbye.php"));
echo $change;
Posted: Sun Jan 21, 2007 10:28 am
by feyd
Unless I'm misunderstanding, yes it's technically possible, but why? I cannot help but wonder if your design isn't optimal if this is required.
Posted: Sun Jan 21, 2007 10:34 am
by iknownothing
thats what the client wants... I dont really see the point either, but what the client wants, the client gets.
How else would you approach it?
Posted: Sun Jan 21, 2007 10:39 am
by feyd
Use variables.
Posted: Sun Jan 21, 2007 10:41 am
by Kieran Huggins
Load the file with
file_get_contents() and then do the
str_replace() on it, then
eval() it.
....then find a client that lets you code properly. If they know enough to insist it's done this way I can't help but wonder why they aren't doing it themselves?
Posted: Sun Jan 21, 2007 10:43 am
by feyd
eval() would be worse I suspect.
Okay, I don't suspect that, it's very likely to blow up.

Posted: Sun Jan 21, 2007 10:44 am
by iknownothing
Kieran Huggins wrote:Load the file with
file_get_contents() and then do the
str_replace() on it, then
eval() it.
....then find a client that lets you code properly. If they know enough to insist it's done this way I can't help but wonder why they aren't doing it themselves?
old grey hair rich people...