Using echo to trace

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
PacoA
Posts: 8
Joined: 12 Nov 2020, 09:31

Using echo to trace

Post by PacoA »

Hi.
It could be a silly question but I had no answer by searching.
Why 'echo' or 'print' doesn´t work?

I´m triyng to trace my code with simple displays but I can´t see them
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Using echo to trace

Post by atrol »

Depends on where you have placed your code.
Your code might not be executed at all, or you can't see the output as the page is sent ompletely new shortly after your code has been executed.

To find out if it's executed, just place some line like

Code: Select all

die ("Hello I am here"); 
in it.
Please use Search before posting and read the Manual
PacoA
Posts: 8
Joined: 12 Nov 2020, 09:31

Re: Using echo to trace

Post by PacoA »

Hi. Thanks.
My code is executing.
Actually I´m tracing by using 'bugnote_add' function.

Even thoug I´v tried your suggestion and it works, the process die ;). But replacing die by echo does anything.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Using echo to trace

Post by atrol »

PacoA wrote: 15 Nov 2020, 12:23But replacing die by echo does anything.
Anything? I suppose you mean nothing.

If I understand right, you want to trace a low level function of Mantis (bugnote_add) by using echo statements.
This is a bad idea in general, as most of the time a new page will be generated after the echo, so you will not see the outpout.
You could add another "die" after your "echo" and I am pretty sure you will see your echo.

It would be better to learn how to debug PHP applications (e.g. by using Xdebug) in general, or use some PHP standard functionality for logging https://www.loggly.com/ultimate-guide/p ... ing-basics or use/check how function log_event is used in Mantis depending on options $g_log_level and $g_log_destination
Please use Search before posting and read the Manual
PacoA
Posts: 8
Joined: 12 Nov 2020, 09:31

Re: Using echo to trace

Post by PacoA »

Sorry about my english. As bad as my php programming.

Of course I meant "nothing".

I´m trying to trace a plugin. I´m using bugnote_add to trace, because I don´t see echoes. Write in a bugnote the text I cannot display.

My code is working. So I don´t need help with that. It´s only that seems strange cannot use echo to trace.

Another reason to hate php :mrgreen:

Anyway, I will check your contributions.

Thank you for your time.
Post Reply