Running PHP 5.5.38, making a basic static function to check if a file exists.
I've tried a lot of different variations and can't see where I'm going wrong here.
<?php
class Configuration {
static function getDetails() {
private $fileContents;
if(file_exists(".\configuration\config.conf")) {
$this->fileContents = file_get_contents(".\configuration\config.conf");
}
elseif(file_exists("..\configuration\config.conf")) {
$this->fileContents = file_get_contents("..\configuration\config.conf");
}
else { $this->fileContents = "Config File Not Found"; }
// Clear cache
clearstatcache();
if(!$config = str_replace(" ", "", $fileContents)) {
echo "No configuration file";
die();
return false;
}
foreach(explode("\n", $config) as $value) {
$value = trim($value);
if(substr($value, 0, 2) == '//' || substr($value, 0, 2) == '/*' ||
substr($value, 0, 2) == '#' || $value == "\n" || $value == ""){
continue;
}
list($k, $v) = explode("=", $value);
$configTemp[$k] = $v;
}
return (object)$configTemp;
}
}
?>
Error output I'm getting,
Parse error: syntax error, unexpected 'private' (T_PRIVATE) in line 8