Re: Re: ECHO

From: Date: Tue, 19 Dec 2006 07:30:35 +0000
Subject: Re: Re: ECHO
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-246006@lists.php.net to get a copy of this message
On 12/18/06, Fahad Pervaiz <fahad.pervaiz@gmail.com> wrote:
I have written a framework for internationalization. Now i have incoorperate it into and existing system that is huge and it will take alot of time to change ECHO to a function call, so i want to override its implementation so that i can use it for my own purposes with having to change all the echo calls
At 12/18/2006 10:01 PM, Casey Chu wrote:
You could try to manipulate what the echo's output by ob_start(), etc. Or maybe you could change the standard output?
Given the probably unalterable nature of echo, I'd say Casey's suggestion of buffering output and running it through a post-processor is an excellent one. However my first choice would probably be to bite the bullet and globally replace echo with my own function. Once that painful step is taken, you can modify the output methodology to your heart's content. This sounds like an excellent object lesson in the separation of logic from markup. If you design your applications to first figure out what to output and then to output it as one or more solid lumps, you can more easily tweak the logic or the markup or the output method without messing with the others. It can be hard medicine to swallow the first time, but it will make you a leaner & cleaner coder. Regards, Paul

« previous php.general (#246006) next »