PHP to check if file exists in a folder for child

I am wanting to have a basic child theme check that works similar to how WP does it.
I have specific files for things like header, footer, content, part etc. much like WP does in its main theme. I want to be able to add a short piece of code in each of those files to check if another (same_named.php) file exists in (dynamic) folder named theme_(anyname).
I did a few tests from much older posts, e.g, PHP Check if dynamic named folder exists
But how do I get it to check for a specific folder and a specific file name that matches the original.
Is there a way to also check for css files as well the same way? I am guessing we can't do the check in the css file itself?
Thanks for your help, it is appreciated.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: deprecated: directive 'allow_url_include' is deprecated in unknown on line 0
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.