Hello This may be a simple question but I am a beginner at php, any help would be greatly appreciated. I am receiving a syntax error in my code at the line where I have $entries = [];
I'm not sure why.
I am new to php so I researched and found out that the []
are arrays but I'm not sure why they are empty or why I am receiving an error. prior to this error I was trying to update plugins on wordpress, then shortly after the site went blank white space and provided this error
Parse error: syntax error, unexpected '[' in /var/www/ctf/wp-content/plugins/user-registration-aide/views/ura-debug.php on line 53
so when I navigated to the file and to the line where the error is i saw this
function debug_log_data(){
$sep = '$!$';
$entries = [];
$log = WP_CONTENT_DIR . '/debug.log';
if ( file_exists( $log ) ){
$fp = @fopen( $log, 'r');
if ($fp) {
while ( ( $line = @fgets( $fp ) ) !== false ) {
$line = preg_replace( "/^\[([0-9a-zA-Z-]+) ([0-9:]+) ([a-zA-Z_\/]+)\] (.*)$/i", "$1".$sep."$2".$sep."$3".$sep."$4", $line );
$parts = explode( $sep, $line );
if ( count( $parts ) >= 4 ) {
$entries[] = [
'date' => date( 'Y/m/d', strtotime( $parts[0] ) ),
'time' => $parts[1],
'timezone' => $parts[2],
'message' => stripslashes( $parts[3] ),
];
}
}
@fclose( $fp );
}
}
return array_reverse( $entries );
}
//}
I'm not sure what the problem is but any help would be appreciated. Thank you for your time.