I have a php file named config.php in which I defined the application settings in an array format like
<?php
return array(
'user' => 'jaison',
'email' => 'test@test.com',
);
?>
Inside the main app files I need to get the array to a variable, so that they can be used like this.
<?php
$settings = include 'config.php';
?>
I would like to know if there is there any alternative method to do like this instead of using include.
Of course there are alternatives, but the way you are doing it is fine (this is how I’d do it) and I know at least of one popular framework that also does this.
The advantage of this method is you don’t have to define any variables inside your include file (which would be imported into the namespace and may be clutter) and the returned structure and can be assigned to whatever is required.