Solved: Errors/ Execptions in PHP

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
User avatar
a.heresey
Forum Commoner
Posts: 59
Joined: Wed Dec 13, 2006 7:31 pm
Location: Chesapeake, VA, US

Solved: Errors/ Execptions in PHP

Post by a.heresey »

I believe I have risen to the level that I need to start "handling" my errors instead of running away from them.

The basic concepts, however, still elude me. Here's an example:

Code: Select all

 if (!valid$_POST['requiredThing']){
  return 'invalid entry, go back';
}else{
  $cornerstone = cornerstonefunc($_POST);
  try{
     append_myDoc($cornerstone, 'myFile.xml');
  }catch(Exception $e){
    echo 'Caught Exception: '. $e->getCode() . ' Message: ' . $e->getMessage(). "\n Couldn't save file.";
  }
  $block1 = $cornerstone->saveXML();
  $stuff = $myXSLTrans($block1, 'myXSL.xsl');
}
$output = '<h1>STUFF</h1>' . $stuff . '<p>Hope you enjoyed that.</p>'
What should happen:

Code: Select all

[size=150]<h1>STUFF</h1>
<p>XML made HTML!</p>
<p>Hope you enjoyed that.</p>[/size]
What does happen:

Code: Select all

[size=150]<h1>STUFF</h1>
<p></p>
<p>Hope you enjoyed that.</p>
[/size]
No errors, no exceptions logged. myFile.xml has the expected output.

I thought that after the try block, lines 10 and 11 would get executed? I'm not very familiar with try...catch, so I think it's the problem.
Last edited by a.heresey on Tue Mar 17, 2009 11:12 pm, edited 1 time in total.
User avatar
a.heresey
Forum Commoner
Posts: 59
Joined: Wed Dec 13, 2006 7:31 pm
Location: Chesapeake, VA, US

Re: Errors/ Execptions in PHP

Post by a.heresey »

Problem was in the xsl. :P
Post Reply