Access env variables in custom php files
If that is really all that you're doing, and you have no other integration with Craft, you can parse the .env however you like. Craft uses vlucas/phpdotenv internally so that library is already in your vendor directory. You should be able to pick that up after including Composer's autoloader.
If however you have any kind if integration with Craft, look at web/index.php and see what's going on in terms of bootstrapping there, copying the parts necessary for your application.