Page 2 of 2
Re: PHP alert?
Posted: Fri Jun 15, 2012 1:04 pm
by Jonah Bron
I just mean that echo automatically casts the variable to string, and outputs whatever that gives.
Re: PHP alert?
Posted: Fri Jun 15, 2012 1:07 pm
by Jonah Bron
Code: Select all
php > $array = array('name' => 'Jerry', 'age' => 30);
php > echo $array;
Array
php > $string = (string) $array;
php > echo $string;
Array
php > var_dump($string);
string(5) "Array"
Re: PHP alert?
Posted: Mon Jun 18, 2012 4:38 pm
by VladSun
Re: PHP alert?
Posted: Thu Jun 21, 2012 5:33 am
by Chris Corbyn
greyhoundcode wrote:Or you could create a function that writes to a log. You could also set up a script that outputs the log, the last 200 entries in reverse chronological order or whatever floats your boat, and keep that open in another tab in your browser. Mix in a little JS magic and it could even refresh itself periodically.
Definitely a good approach. You can just tail a file when you're developing this way and see what appears in the log output.
Other languages do this the other way around. PHP's default behaviour is to send STDOUT to the browser, while, say Ruby on Rails will output that data into the console.
Re: PHP alert?
Posted: Wed May 22, 2013 9:47 am
by johngill2810
Hello,
There is no alert function in php.Forc such purpose you have to use java script.
Java script has a alert function which use to alert any information on window.
Re: PHP alert?
Posted: Wed May 22, 2013 12:13 pm
by requinix
Since it seems this thread ranks well for some searches,
If you need something for generic debugging,
console.log is supported by all major browsers and much nicer than using alert().
Re: PHP alert?
Posted: Thu May 23, 2013 1:17 pm
by Eric!
I sometimes redirect debugging info and use php error handler to pipe into a database (or a file), then use javascript via ajax to a php tool that looks for new entries and reports them. Then javascript can lightbox them or put them into console.log. This way the you see the html as it would appear without the debugging stuff or errors intermixed.
Fatal errors have to be viewed from a different page that is functional and has the javascript ajax code. I usually keep that ready to refresh in a separate tab.