Hallo liebe Community,
leider benötige ich schon wieder eure hilfe. Bei meinem versuch bzgl. eines Logsystems erhalte ich beim erzeugen der Class diesen fehler:
MySQL.inc.php
LogSystem.php
Danke für eure hilfe.
leider benötige ich schon wieder eure hilfe. Bei meinem versuch bzgl. eines Logsystems erhalte ich beim erzeugen der Class diesen fehler:
HTML-Code:
Fatal error: Constant expression contains invalid operations in C:\\htdocs\dashboard\assets\php_inc\MySQL.inc.php on line 18
PHP-Code:
<?php
include 'LogSystem.php';
use LogSystem\LogSystem as LogSyS;
class MySQL extends LogSystem{
const FILEPATH = "";
private $hostname = null;
private $port = null;
private $username = null;
private $password = null
; private $dbname = null;
public $Log = new LogSyS();
function __construct() {
$conData = getConnectionData();
$this->hostname = $conData->hostname;
$this->port = $conData->port; $this->username = $conData->username;
$this->password = $conData->password; $this->dbname = $conData->dbname;
}
function createMySQLConnection() {
try {
$pdo = new PDO('mysql:host=localhost;dbname=test', 'username', 'password');
} catch(Exeption $e) {
}
}
private function getConnectionData() {
$handle = fopen (self::FILEPATH, "r");
$rawData = json_decode(fread ($handle, filesize ($dateinamen)));
fclose ($handle);
return $rawData; } } ?>
PHP-Code:
<?php
class LogSystem {
public const ERRORFILEPATH = "../data/Log.log";
public function __construct() {
}
public function writeLogEvent($ErrorType, $ErrorMessage) {
$timestamp = time();
$datum = date("H:i:s - d.m.Y", $timestamp);
$ErrorString = "[" + $datum + "] " + $ErrorType + " = " + $ErrorMessage;
if(!(file_exists(self::ERRORFILEPATH))) { if(!(createNewLogfile())) throw new Exception("Error Processing 'createNewLogfile' Request", 1);
}
if(!(file_put_contents(self::ERRORFILEPATH, $ErrorString, FILE_APPEND))) throw new Exception("Error Processing 'writeContent' Request", 1);
return true;
}
/* * @return boolean true if everything was correct | false if errors occurred */ private function createNewLogfile() {
try { $datei = fopen(self::ERRORFILEPATH, 'w'); fwrite($datei, null); fclose($datei); return true; } catch(Exeption $e) { return false; } ?>
Kommentar