Jump to content

undefined constant in php 8.0 but in 7.4 works


royer

Recommended Posts

// Hello all code champions, the problem is that: when running my project in php 8.0, especially this class is damaged and cannot be recognized by visual studio code, causing everything associated with this file to be displayed undefined .. but if my project runs in 7.4 it works great ... also in the obsolete functions I haven't found anything ...
I hope someone can help me

<? php

register_shutdown_function ( función () { 
    $error = error_get_last (); if ( is_array ( $error ) && $error [ 'tipo' ] === E_ERROR ) { 
        $tipo = $error [ 'tipo' ]; 
        $mensaje = $error [ 'mensaje' ]; 
        $línea = $error [ 'línea' ]; 
        $archivo = $error [  
        'archivo' ]; intente { Cargar :: registro ( "\nTipo de error: $tipo, encontrado en $archivo:$línea, con mensaje de error: $mensaje" ); } catch ( Excepción ) { } 
        $código = definido ( 'Constante::ERRORLOG' ) ? 2001 : 2000 ; 
        $mensaje = (! definido ( 'Constante::ERRORLOG' ) ? 'Error Constante' : ( Constante :: ERRORLOG ? $error [
          
            
           
                  'mensaje' ] . 'archivo:' . $error [ 'archivo' ] . 'línea: ' . $error [ 'línea' ] : 'Error fatal' ));        

        http_response_code ( 500 ); if ( $_SERVER [ 'SCRIPT_NAME' ] == '/index.php' || $_SERVER [ 'SCRIPT_NAME' ] == '/home.php' ) { 
            $plantilla = file_get_contents ( $_SERVER [ 'DOCUMENT_ROOT' ] . ' /static/html/error500.html' );   
            $html = str_replace ( '@codigo@' , $codigo , $plantilla ); 
            $html
                 = str_replace ( '@mensaje@' , $mensaje , $html ); 
            eco $html ; } elseif ( definido ( 'Constante::ERRORLOG' ) && Constante :: ERRORLOG ) { die ( json_encode ([ 'estado' => falso , 'datos' => nulo , 'error' => [ 'descripción' => ' Hubo un error en RS-C: ' . $mensaje ,
           
                         => 'SC3000' , 'mensaje' => 'Ocurrió un error' ]])); } } });    
        
    


$practicas = json_decode ( file_get_contents ( "/conect/practicas.json" ), true ); 
$host = $_SERVER [ "HTTP_HOST" ] ?? ( $_SERVER [ "argv" ][ 1 ] ?? "" ); 
$inicial = $practicas [ $host ] ?? "" ;       

prueba { 
    $config = json_decode ( file_get_contents ( "/conect/constantes" . $inicial . ".json" ), true , 512 , JSON_THROW_ON_ERROR );     

} captura ( excepción ) { }   


$declaracion = "" ; 

if ( isset ( $host ) && preg_match ( "/-test./" , $host )) { if ( isset ( $config [ "_CONECCIONES_TEST" ])) { 
        $config [ "_CONECCIONES" ] = $config [ "_CONECCIONES_TEST " ]; 
        $config [ "DOMINIO" ] = $config [ "DOMINIO_TEST" ]; 
        $config [ "DOMINIO_ESTATICO"   
         $config [ "DOMINIO_ESTATICO_TEST" ]; 
        $config [ "TITULO" ] = $config [ "TITULO_TEST" ]; 
        $config [ "BASEWEB" ] = $config [ "BASEWEB_TEST" ]; 
        $config [ "BASETIK" ] = $config [ "BASETIK_TEST" ]; 
        $config [ "BASEQCF" ] = $config [ "BASEQCF_TEST" ]; 
        $configuración [ "     = $config [ "APLICACIONES" ]; 
        $config [ "TEXT" ] = $config [ "TEXT_TEST" ]; 
        $config [ "AUTH_TWO_STEP" ] = $config [ "AUTH_TWO_STEP_TEST" ];  

    // $config["USAP"]=$config["USAP_TEST"]; } else { 
        $config [ "_CONECCIONES" ] = []; 
        $config [ "DOMINIO" ] = $config [ "DOMINIO_TEST" ]; 
        http_response_code ( 404 ); morir ( file_get_contents ( 'static/html/error404.html' )); } } foreach ( $config as $key => $value ) { if ( $key ==
         
        
    

  
      "APLICACIONES" ) { 
        $declaración .= 'const APLICACIONES = ' . var_export ( $ valor , verdadero ) . ';' ; foreach ( $valor como $índice => $valor ) { 
            $declaración .= 'const' . $índice . ' = "' . $valor . '";' ; } } más { si ( is_array ( $ valor )) {      
               
        
      
          
            $declaración .= 'public static $' . $clave . ' = ' . var_export ( $ valor , verdadero ) . ';' ; 
            $keyTmp = str_replace ( "_" , "" , $key ); 
            $declaración .= 'const' . $teclaTmp . ' = ' . var_export ( $ valor , verdadero ) . ';' ; } más {               
          
            $declaración .= 'const' . $clave . ' = "' . $valor . '";' ; } } }     
        
    


eval ( "clase Constante { $declaracion }" ); if ( definido ( 'Constante::ERRORLOG' ) && Constante :: ERRORLOG ) { //ini_set('visualizar_errores', \Sistema::IS_DEBUG); //informe_error(\Sistema::IS_DEBUG); }
    
    
    

 

Link to comment
Share on other sites

Hello all code champions, the problem is that: when running my project in php 8.0, especially this class is damaged and cannot be recognized by visual studio code, causing everything associated with this file to be displayed undefined .. but if my project runs in 7.4 it works great ... also in the obsolete functions I haven't found anything ...
I hope someone can help me. 
to clarify that the route file is a json that sends the constants to php

 

Edited by royer
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.