Link to home
Create AccountLog in
Avatar of Simon336697
Simon336697Flag for Australia

asked on

Outputting error messages in a php page

Hi guys hope you can help.

I have a simple php page as follows....

----------------------------------------------------------------------------------------- testing.php
<pre>
<?php
echo htmlspecialchars(shell_exec('dir c:\wamp\www'));
?>
</pre>
-----------------------------------------------------------------------------------------

What this will output is a directory listing of the folder c:\wamp\www.

However, Id like to know if this command failed for any reason.

For example, if I changed the dummy folder name that doesnt exist on my system, eg.

C:\>dir c:\ps
 Volume in drive C has no label.
 Volume Serial Number is 74DC-C9FB

 Directory of c:\

File Not Found

-----------------------------------------

But currently, if I placed c:\ps into my php page, and tested this out to check for errors,

----------------------------------------------------------------------------------------- testing.php
<pre>
<?php
echo htmlspecialchars(shell_exec('dir c:\ps'));
?>
</pre>
--------------

I just get a blank page and dont get any error messages on the page.

Any help on how to output any errors on the page would be most appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account