Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    1,316

    instanceof non funziona

    index.php
    Codice PHP:
    <?php
    /** 
     * Set exception handler 
     */
    set_exception_handler(array('system\bootstrap\Blind''exceptionHandler'));

    /** 
     * Set php error handler 
     */
    set_error_handler(array('system\bootstrap\Blind''errorHandler'), E_ALL);

    // [...]

        
    public static final function exceptionHandler(\Exception $e) {            
          
    // var_dump($e);        
          
    if ($e instanceof IException) { 
            
    $e->show(); 
          }
        }
      
        public static final function 
    errorHandler($errorNo$message$filename$lineNo) {            
          throw new 
    BlindException($errorNo$message$filename$lineNo);
        }
    includes/Error/BaseErrorHandler.php
    Codice PHP:
    <?php
    namespace Error;

    class 
    BaseErrorHandler extends \Exception {
      
    // [...]
    }
    includes/Error/BlindException.php
    Codice PHP:
    <?php
    namespace Error;

    class 
    BlindException extends BaseErrorHandler implements IException {
      public function 
    show() {
        die(
    "show");
      }
    }
    includes/Error/IException.php
    Codice PHP:
    <?php
    namespace error;

    interface 
    IException {  
      public function 
    show();
    }
    Perchè l'if ($e instanceof IException) ​non viene eseguito?

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    1,316
    up

  3. #3
    Non hai specificato il namespace dell'interfaccia: nella index.php o fai
    Codice PHP:
    use Error\IException
    oppure specifichi il nome completo:
    Codice PHP:
    if ($e instanceof \Error\IException) { 

  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2008
    Messaggi
    1,316
    grazie gentilissimo

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 © 2024 vBulletin Solutions, Inc. All rights reserved.