0

Can I override the PHP function echo()?

I need append text to echo

echo "text";

function echo($string)
{echo $string ." in line : ". __LINE__;}
omid zahed
  • 21
  • 1
  • 5
  • you mean you want change the function name as echo? – Syamlal Feb 26 '20 at 07:23
  • You could look at how to use output buffering so that you can capture the output instead. – Nigel Ren Feb 26 '20 at 07:24
  • 1
    `echo` is not a function it's a language construct. It's also a [reserved word](http://php.net/reserved) in PHP. You cannot reuse reserved words. – Sherif Feb 26 '20 at 07:25
  • I need append text to echo return – omid zahed Feb 26 '20 at 07:27
  • Just create another function e.g. `dump('some info here')` instead of trying to override `echo` – DarkBee Feb 26 '20 at 07:34
  • Stab into the dark: you're trying to debug where a particular piece of output is coming from? You better do that with a debugger and setting breakpoints. That may be slightly tricky to set up the first time, but is an invaluable tool once you know it. – deceze Feb 26 '20 at 07:46
  • yes I use xdebug but there are a lot of loop and file – omid zahed Feb 26 '20 at 07:54

0 Answers0