You could make the variable static, as long as it doesn't need to allow differentiation across instances (i.e. instance variable):
<?php
// example code
abstract class Settings
{
public static $application = array
(
'Name' => 'MyApp',
'Version' => '1.0.0',
'Date' => 'June 1, 2017'
);
}
echo Settings::$application ['Name'];
Run it in this playground example.
Though your original access of application
was similar to that of a constant. use const
to declare a Class constant:
abstract class Settings
{
const application = array
(
'Name' => 'MyApp',
'Version' => '1.0.0',
'Date' => 'June 1, 2017'
);
}
echo Settings::application ['Name'];
Run it in this playground example.