A: yes... from the perspective of the trailing question, "Does this make my PHP project vulnerable in any way?"
I'll assume that in the config file you have salt/pepper, database credentials, and other parameters that you might find in an ownCloud or Wordpress config.php file, the sort of which would hold value for an adversary.
If your config.php is exposed in your lower environment, you are making production-environment configuration parameters available in this file. Just about anything can happen in a dev environment, where as hopefully your production environment is a little more locked down. The potential for exposure is greater by having all the configuration parameters in the one file.
And for the rigid interpretation of your question...
Your config.php file would not in any way be less safe if you had an if/else or other branching conditional and the logic was correct. The potential for the contents of this file to be exposed under normal
php and web server operation is no different than if you had separate files per environment. With respect to safe, see the other answer that @mti2935 linked to (in a comments against this question) that discusses the safety of the variables in the
$_SERVER dict, ie. which parameters can be influenced by the user.
Another observation - with a branching conditional, you're relying on correct implementation of the web server and
php interpreter to prevent the user influencing the contents of the
$_SERVER dict. I don't have time at the moment to find an example, but there's a large number of vulnerability records to wade through: https://nvd.nist.gov/vuln/search/results?form_type=Basic&results_type=overview&query=%24_SERVER&queryType=phrase&search_type=last3years