?
Solved

Extend output from logging to include the .php file the line number in that php file variables and values used on that line

Posted on 2014-03-12
3
Medium Priority
?
348 Views
Last Modified: 2014-03-17
I am very much of the opinion that you can't have too much information and either by extending the logging threshold values, outputting more or less data, or by analysis of the output to achieve what I want to see this time.

I would like to trace the path of my  code outputting parameters set or used is this possible and where would I start?

Thanks very much for listening I hope to hear from you

John
0
Comment
Question by:johnecollins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39923301
Yes, it is possible.  Nobody much does this any more, because object oriented design makes it unnecessary to trace logic - the amounts of code in any method are usually so small that "spaghetti logic" simply does not occur.  But that said, PHP has some tools that can help you do this.

There are the magic constants.  You can print or log these.
http://www.php.net/manual/en/language.constants.predefined.php

Data visualization is available with var_dump(). Especially useful for invisible variables like $_COOKIE and $_SESSION.
http://www.php.net/manual/en/function.var-dump.php

You can log any information you want with error_log()
http://www.php.net/manual/en/function.error-log.php

I have not used it (intentionally) but there is this:
http://www.php.net/manual/en/function.debug-backtrace.php

This article is a little old, but it hits many of the right notes.  Probably XDebug belongs on your short list:
http://coding.smashingmagazine.com/2009/01/20/50-extremely-useful-php-tools/

Since I began PHP before PHP4, I developed my own crude error handlers and tracing process.  In my ancient design, I would set a $debug variable in the script common logic.  And I had a debug() function that I called at various points throughout the script.  If the $debug variable was not set, the function did nothing.  If the $debug variable was set, the debug() function would gather and write a collection of data.  At the end of the script, if the $debug variable was set, the script would conclude by sending me an email message pointing to the file of debugging data.  None of this is necessary any more, since most of my work is OOP.
0
 

Author Closing Comment

by:johnecollins
ID: 39933569
Ray, thanks very much for your help I have had a good read and my knowledge has grown and helped me progress my development

Thanks a lot

John
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39933886
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question