royer Posted July 11, 2022 Share Posted July 11, 2022 // 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); } Quote Link to comment https://forums.phpfreaks.com/topic/315027-undefined-constant-in-php-80-but-in-74-works/ Share on other sites More sharing options...
royer Posted July 11, 2022 Author Share Posted July 11, 2022 (edited) 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 July 11, 2022 by royer Quote Link to comment https://forums.phpfreaks.com/topic/315027-undefined-constant-in-php-80-but-in-74-works/#findComment-1598140 Share on other sites More sharing options...
mac_gyver Posted July 11, 2022 Share Posted July 11, 2022 that's not a valid opening php tag. it should be <?php (no space) 1 Quote Link to comment https://forums.phpfreaks.com/topic/315027-undefined-constant-in-php-80-but-in-74-works/#findComment-1598142 Share on other sites More sharing options...
royer Posted July 11, 2022 Author Share Posted July 11, 2022 Jajajaja is right but in my code is correct Quote Link to comment https://forums.phpfreaks.com/topic/315027-undefined-constant-in-php-80-but-in-74-works/#findComment-1598143 Share on other sites More sharing options...
requinix Posted July 12, 2022 Share Posted July 12, 2022 Does your code also say "función" and "definido" and "prueba/captura"? Post your actual code. Quote Link to comment https://forums.phpfreaks.com/topic/315027-undefined-constant-in-php-80-but-in-74-works/#findComment-1598155 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.