displaying error messages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zitpig
Forum Newbie
Posts: 3
Joined: Fri Sep 26, 2003 2:48 am

displaying error messages

Post by zitpig »

Hello all,
I'm new to php, and am excited about learning it.
I've got php4 installed on win98, and am using pws 4.
I understand php3 came with a debugger, but php4 has none.
Is there any way to get error messages displayed in the browser. I've got 'display_errors = On' and 'error_reporting = E_ALL' ... (not exactly sure what these mean). Currently, if there's an error in my code, the browser shows a blank. I've discovered using the DOS window and calling php.exe with the php file name to see some errors, but I can't believe this is the best way to do it.

Any sugestions appreciated,
Zitpig.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

can you copy and paste that section of your PHP.ini.

What you have described should work.

Mark
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

When you check the output of

Code: Select all

<?php
phpinfo();
?>
What does it say about display_errors and error_reporting? Occasionally people find that they have possibly edited the wrong php.ini and thus the changes they make don't take effect.

Mac
zitpig
Forum Newbie
Posts: 3
Joined: Fri Sep 26, 2003 2:48 am

Post by zitpig »

Mark and Mac,

I did a phpinfo() and it just reflected my ini file, but I also got error messages in the browser. The only different thing I'd done was restarting the computer. I thought that every time php starts it reads the ini file, but it must read it once a session(?)....does php have sessions? Anyway, I now know to reboot whenever I change the ini file.
I also found display_startup_errors = Off and changed it to on, but I'm not sure what this does.

Thanks.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You dont need to reboot the computer per se, but the webserver. Check it's documents on how to do that.

To continue, posting some of the error msg's would help, and if those refers to a specific line somewhere, that line of code would be helpful also.
zitpig
Forum Newbie
Posts: 3
Joined: Fri Sep 26, 2003 2:48 am

Post by zitpig »

Stopping and restarting the server...of course.
Doesn't seem to be the case with PWS though, unless I'm just not waiting long enough before restarting. (I couldn't find anything in the php help that says how long sessions hang around for before they die. With ASP on PWS, session variables can stay viable for minutes after the browser has been closed).
I was just interested in getting error messages printed to the browser window, and that seems to be happening now.

An eg of the this...

<?php
$name = "peter" ?>
The value in the variable <i>name</i> is <?php= $name ?>.

Causes this output into the browser...

Parse error: parse error, unexpected '=' in D:\_work1\php\php4.php on line 3

I discovered that this is fixed by using the short form of the delimiter...

<?=$name ?>

rather than the longer form ...

<?php=$name ?>

Cheers.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

<?= expression ?> is the same as <?php echo expression ?> if short_tags are enabled. There is no tag <?php= ?>

see also: http://www.php.net/manual/en/configurat ... ge-options
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

If you have issues with sessions, you can try to delete them. You state the whereabouts in the php.ini.
Post Reply