ECHO

This is a discussion on ECHO within the PHP General forums, part of the PHP Programming Forums category; ECHO is a language construct but still is there any work around to override it or change its functionality???...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-19-2006
Fahad Pervaiz
 
Posts: n/a
Default ECHO

ECHO is a language construct but still is there any work around to override
it or change its functionality???

Reply With Quote
  #2 (permalink)  
Old 12-19-2006
Casey Chu
 
Posts: n/a
Default Re: [PHP] Re: ECHO

You could try to manipulate what the echo's output by ob_start(), etc.
Or maybe you could change the standard output?

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
>
> --
> Regards
> Fahad Pervaiz
> www.ecommerce-xperts.com
>
>

Reply With Quote
  #3 (permalink)  
Old 12-19-2006
Fahad Pervaiz
 
Posts: n/a
Default Re: ECHO

Manipulating out with Output Control Functions sounds a good idea but it can
become cumbersome.

Do you know any good methods to control standard output??


On 12/19/06, Casey Chu <heavyccasey@gmail.com> wrote:
>
> You could try to manipulate what the echo's output by ob_start(), etc.
> Or maybe you could change the standard output?
>
> 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
> >
> > --
> > Regards
> > Fahad Pervaiz
> > www.ecommerce-xperts.com
> >
> >

>



--
Regards
Fahad Pervaiz
www.ecommerce-xperts.com

Reply With Quote
  #4 (permalink)  
Old 12-19-2006
Chris
 
Posts: n/a
Default Re: [PHP] ECHO

Fahad Pervaiz wrote:
> ECHO is a language construct but still is there any work around to override
> it or change its functionality???


Nope. You're stuck with how it works now.

--
Postgresql & php tutorials
http://www.designmagick.com/
Reply With Quote
  #5 (permalink)  
Old 12-19-2006
Paul Novitski
 
Posts: n/a
Default Re: [PHP] Re: ECHO


>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
Reply With Quote
  #6 (permalink)  
Old 12-19-2006
Jochem Maas
 
Posts: n/a
Default Re: [PHP] ECHO

Fahad Pervaiz wrote:
> ECHO is a language construct but still is there any work around to override
> it or change its functionality???


if your willing to hack the php source then you can pretty much do whatever you want;
that said there is no mechanism for overriding echo or any other language construct in
the std php...

there is runkit (http://php.net/runkit) but that doesn't seem to offer language construct
overriding based on a quick glance.



>

Reply With Quote
  #7 (permalink)  
Old 12-19-2006
Satyam
 
Posts: n/a
Default Re: [PHP] Re: ECHO

You could use the PHP Compiler: http://phpcompiler.org/ and do a
preprocessor as I did: http://www.satyam.com.ar/pht/.

PHC is capable of compiling a PHP source and return a modified PHP source.
It is easy to make a plugin for any such modifications, there is a class
which gets instantiated after parsing and makes a full tree traversal with a
method defined for each node type so you simply inherit from the method for
your particular tree node and make any modifications you want to it.

For PHC echo is not a language construct, you would have to override the
"method invocation" method, check whether the function name is "echo" (print
is translated to echo) and then do your changes. One of the tutorials
shows you how to do this: http://phpcompiler.org/doc/tutorial2.html

Satyam


----- Original Message -----
From: "Fahad Pervaiz" <fahad.pervaiz@gmail.com>
To: <php-general@lists.php.net>
Sent: Tuesday, December 19, 2006 6:46 AM
Subject: [php] Re: ECHO


>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
>
> --
> Regards
> Fahad Pervaiz
> www.ecommerce-xperts.com
>

Reply With Quote
  #8 (permalink)  
Old 12-19-2006
Fahad Pervaiz
 
Posts: n/a
Default Re: ECHO

Thank you Satyam for you help! i think this is the rite solution

On 12/19/06, Satyam <Satyam@satyam.com.ar> wrote:
>
> You could use the PHP Compiler: http://phpcompiler.org/ and do a
> preprocessor as I did: http://www.satyam.com.ar/pht/.
>
> PHC is capable of compiling a PHP source and return a modified PHP source.
> It is easy to make a plugin for any such modifications, there is a class
> which gets instantiated after parsing and makes a full tree traversal with
> a
> method defined for each node type so you simply inherit from the method
> for
> your particular tree node and make any modifications you want to it.
>
> For PHC echo is not a language construct, you would have to override the
> "method invocation" method, check whether the function name is "echo"
> (print
> is translated to echo) and then do your changes. One of the tutorials
> shows you how to do this: http://phpcompiler.org/doc/tutorial2.html
>
> Satyam
>
>
> ----- Original Message -----
> From: "Fahad Pervaiz" <fahad.pervaiz@gmail.com>
> To: <php-general@lists.php.net>
> Sent: Tuesday, December 19, 2006 6:46 AM
> Subject: [php] Re: ECHO
>
>
> >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
> >
> > --
> > Regards
> > Fahad Pervaiz
> > www.ecommerce-xperts.com
> >

>
>



--
Regards
Fahad Pervaiz
www.ecommerce-xperts.com

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:24 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0