As you know var_dump()
in addition to value show its data type and length.
Is there any way to log its output to FireBug console?
I tried FirePHP and FireLogger but both output only value of a variable (sometimes even incorrect variable value).
As you know var_dump()
in addition to value show its data type and length.
Is there any way to log its output to FireBug console?
I tried FirePHP and FireLogger but both output only value of a variable (sometimes even incorrect variable value).
I always use this script in combination with Zend_Log_Writer_Firebug (using firephp http://www.firephp.org/), because after redirects in the applicaton or ajax requests debugging with xdebug does not always work as expected:
You can build your own library to get the type of a variable:
Using a function call to var_dump_ret as argument for $logger->info() might be helpful, too. I haven't tested it yet.
The following will take anything from var_dump() and encode it in JSON before attempting to send it to console.log(). This prevents and special characters from messing up the output.
I think one easy way to achieve this goal is to do a simple
console.log(<?php var_export($var, true) ?>);
You can dump JavaScript to the console by putting a console.log() in a script tag:
So if you do a php dump in there...
You just need to be careful about ' and " in the var_dump breaking your JavaScript. In this example it will be ok because the HTML would be:
Just remember the php is processed then put in the JavaScript. You could also dump it to a comment:
Then you can view source, or inspect element.
only from JavaScript a jquery From arrays in firebug and chrome is:
open the console and activate to F12... and write this code in console is the var_dump to php from jquery. array to json
if you need directly console fron PHP need a plugin
You are over complicating what is a simple issue. Firebug (and any other console/dom log viewer is for viewing client side output. PHP being server side and doesn't make much sense pushing to the console log.
With that said, if you REALLY wanted to pipe a server-side output to the console log you should convert that output into json and pass it onto the console log. If you simply want to output variable values on a life site without people knowing that you are working on it (and you shouldn't be working on a live version anyway but that's beside the point) why not pipe the output to a file and read that output however you like, you could even use ajax to pass the dump off to the log via jquery.
The point I am trying to make is...you are over-complicating what you are trying to do.