Scrivi $dsn e poi $dns.
$options = simplexml_load_file("data/woo_options.xml");
$dsn = (string) $options->dsn;
print $dns;
Scrivi $dsn e poi $dns.
$options = simplexml_load_file("data/woo_options.xml");
$dsn = (string) $options->dsn;
print $dns;
Ridatemi i miei 1000 posts persi !!!!
Non serve a nulla ottimizzare qualcosa che non funziona.
Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr
Uuuuuuu! Hai ragione, grazie! Ho provato a correggere ma ho ottenuto nuovamente questo:
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
NUOVO CODICE CON ERRORE:
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 $dsn;
}
}
$d = (new ApplicationHelper())->getOptions();
}
namespace woo\base {
class AppException extends \Exception {
}
}
?>
Più pratica in futuro...
Su questo sono d'accordo ma il problema ora è l'eccezzione, cioè se scrivo questo:
Codice PHP:<?php
namespace woo\controller {
// woo\controller\ApplicationHelper
class ApplicationHelper {
function getOptions() {
if (!file_exists("data/woo_options_not_there.xml")) {
print "Non riesco ad aprire il file<br>";
}
$options = simplexml_load_file("data/woo_options.xml");
$dsn = (string) $options->dsn;
print $dsn;
}
}
$d = (new ApplicationHelper())->getOptions();
}
namespace woo\base {
class AppException extends \Exception {
}
}
?>
funziona ma io voglio capire come chiamare AppException che si trova in un altro namespace...
![]()
Più pratica in futuro...