I am trying to debug some code. I want to show the variables defined in try in catch . For example, the variable $siteId .
<?php try { $siteId = 3; if(1 !== 2) { throw new Exception('1 does not equal 2!'); } } catch(Exception $e) { $moreInfo = ''; if(isset($siteId)) { $moreInfo .= ' SiteId»' . $siteId; } echo 'Error' . $moreInfo . ':' . $e->getMessage(); } ?>
The answer I get is Error: 1 does not equal 2! instead of Error SiteId»3: 1 does not equal 2! . What am I doing wrong?
source share