PHP alert?
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: PHP alert?
I just mean that echo automatically casts the variable to string, and outputs whatever that gives.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: PHP alert?
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?
Alternatives: http://www.firephp.org/
There are 10 types of people in this world, those who understand binary and those who don't
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: PHP alert?
Definitely a good approach. You can just tail a file when you're developing this way and see what appears in the log output.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.
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.
-
johngill2810
- Forum Newbie
- Posts: 6
- Joined: Tue May 14, 2013 9:52 am
Re: PHP alert?
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.
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?
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().
If you need something for generic debugging, console.log is supported by all major browsers and much nicer than using alert().
Re: PHP alert?
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.
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.