-1
Notice: Undefined variable: strErro
<?php
class DB{
private static $conn;
static function getConn(){
if(is_null(self::$conn)){
self::$conn = new PDO('mysql:host=localhost;dbname=sllapsocial','root','');
self::$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
return self::$conn;
}
}
function logErros($errno){
if(error_reporting()==0) return;
$exec = func_get_arg(0);
$errno = $exec->getCode();
$errstr = $exec->getMessage();
$errfile = $exec->getFile();
$errline = $exec->getLine();
$err = 'CAUGHT EXCEPTION';
if(ini_get('log_errors')) error_log(sprintf("PHP %s: %s in %s on line %d",$err,$errstr,$errfile,$errline));
$strErro = 'erro:'.$err.' no arquivo: '.$errfile.' ( linha '.$errline.' ) :: IP('.$_SERVER['REMOTE_ADDR'].') data:'.date('d/m/y H:i:s')."\n";
}
$arquivo = fopen('logerro.txt','a');
//Aparece aqui Notice: Undefined variable: strErro estou fazendo corréto?
fwrite($arquivo,$strErro);
fclose($arquivo);
set_error_handler('logErros');
Put the
return $strErro
at the end oflogErros()
?– rray
Amazing how a simple indentation CORRECT plays the error to the eyes.
– Papa Charlie
@Papacharlie, for it is first thought if it was not excutado then saw that it was a one line if =\
– rray
Yeah, that one
}
after$strErro
is tense, kills any logic - you think it’s one thing but it’s another. The code has "reverse indentation" oo– Papa Charlie
The PDO has nothing to do with it. The problem is that you have N³ mistakes, and when you get one, it appears next, and then another...
– Papa Charlie
Use file_put_contents
– Papa Charlie