PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
iknownothing
Forum Contributor
Posts: 337 Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia
Post
by iknownothing » Sun Jan 21, 2007 10:15 am
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;
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Jan 21, 2007 10:28 am
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.
iknownothing
Forum Contributor
Posts: 337 Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia
Post
by iknownothing » Sun Jan 21, 2007 10:34 am
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Jan 21, 2007 10:39 am
Use variables.
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Sun Jan 21, 2007 10:41 am
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Jan 21, 2007 10:43 am
eval() would be worse I suspect.
Okay, I don't suspect that, it's very likely to blow up.
iknownothing
Forum Contributor
Posts: 337 Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia
Post
by iknownothing » Sun Jan 21, 2007 10:44 am
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...