Visualizzazione dei risultati da 1 a 10 su 13

Hybrid View

  1. #1
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,373
    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

  2. #2
    Quote Originariamente inviata da badaze Visualizza il messaggio
    Scrivi $dsn e poi $dns.

    $options = simplexml_load_file("data/woo_options.xml");
    $dsn = (string) $options->dsn;
    print $dns;
    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...

  3. #3
    Quote Originariamente inviata da badaze Visualizza il messaggio
    Scrivi $dsn e poi $dns.

    $options = simplexml_load_file("data/woo_options.xml");
    $dsn = (string) $options->dsn;
    print $dns;
    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...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.