PHP alert?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP alert?

Post by Jonah Bron »

I just mean that echo automatically casts the variable to string, and outputs whatever that gives.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP alert?

Post 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"
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP alert?

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP alert?

Post 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.
johngill2810
Forum Newbie
Posts: 6
Joined: Tue May 14, 2013 9:52 am

Re: PHP alert?

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP alert?

Post 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().
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PHP alert?

Post 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.
Post Reply