Trace source file of an error_log php

201 views Asked by At

I often use error_log to output information when I am developing stuff so I can see the content of arrays and such- I am not sure if this is a good way of doing things but I am self taught so forgive me!

Anyway, somewhere I must have forgotten to comment an error_log out because I am continuously getting an error_log message of 'post_type=' and for the life of me I just cannot track it down, I have done a search for 'post_type=' in all of my files and also been through every error_log I can find and checked that it is commented out but just cannot track this darn thing down...

SO what I was wondering is if anyone knows how I can trace the source of the last error_logged message so I can find the file that is sending it. I tried error_get_last() but this isn't returning anything I think because its not actually an error that is getting logged but a message I am outputting manually...

Failing that, I see that in Dreamweaver there is a way to search using regular expressions and was just wondering if anyone knows how I can make it search for error_log that not preceded by '//'

Thanks in advance :)

1

There are 1 answers

3
Loïc On

You can change your error log file permissions to nothing, so only "root" user has access to it. Then navigate on your website, and hopefully at some point you'll trigger that error, and as Apache won't have the rights to write in this file, php will trigger an error, giving you the opportunity to know from where it comes.

Also, if you are willing to see the content of a variable, you can use var_dump($myVar).