Perché non riesco a stampare $dns?
Codice PHP:<?php
namespace woo\controller {
class ApplicationHelper {
function getOptions() {
if (!file_exists("data/woo_options_not_there.xml")) {
throw new \woo\base\AppException(
"Could not find options file");
}
$options = simplexml_load_file("data/woo_options.xml");
$dsn = (string) $options->dsn;
print $dns;
}
}
$d = (new ApplicationHelper())->getOptions();
}
namespace woo\base {
class AppException extends \Exception {
}
}
?>
questo è l'errore:
Fatal error: Uncaught exception 'woo\base\AppException' with message 'Could not find options file' in C:\xampp\htdocs\9781430260318_Chapter_12_Code\list ing12.00.php:9 Stack trace: #0 C:\xampp\htdocs\9781430260318_Chapter_12_Code\list ing12.00.php(19): woo\controller\ApplicationHelper->getOptions() #1 {main} thrown in C:\xampp\htdocs\9781430260318_Chapter_12_Code\list ing12.00.php on line 9

Rispondi quotando


...)
Premetto che preferisco adottare le parentesi perché il libro per comudità usa queste anche in esempi più avanti ma comunque credo non siano queste a dar fastidio. Su tuo consiglio ho provato a scrivere: