4
Is there any way to debug PHP via browser console?
I sometimes want to debug a value on the system in production, but I wouldn’t want the user to notice. Then I got the idea to use the browser console.
It’s possible to do something like this:
console_log(['nome' => 'Wallace']);
And on the console appear:
{nome: "wallace"}
Very good idea to post here, I’ve done this several times, but always found it a master monster gambiarra but breaks a branch.
– Ricardo
Very interesting, but I thought it would be something to pause the code. This wouldn’t just be data display?
– Guilherme Lautert
I call debugging also display the variable value (as in var_dump)
– Wallace Maxters
you do not like the Xdebug no?
– Rafael Mena Barreto
It depends. Sometimes he fills the bag with the business of Maximum call 100, in recursion
– Wallace Maxters
@Wallacemaxters I think I saw this in this post: http://www.paulund.co.uk/output-php-data-in-browser-console to debug a production result is good, but still anyone with access to the console could see, tested some plugins pro Chrome as https://Chrome.google.com/webstore/Detail/php-console/nfhmhhlpflenkpnnnkolmclajemef and did not produce good results...
– Gabriel Rodrigues
@Wallacemaxters take a look at this one: http://www.codeforest.net/debugging-php-in-browsers-javascript-console looks much more complete.
– Gabriel Rodrigues
@Gabrielrodrigues, I prefer to use
json_encode
in all values. You can see thetrue
,false
andnull
. PHP will print a blank if you follow the link example– Wallace Maxters