Most people working in the industry for years get confused about how to check whether a file exists or not programmatically in Magento 2. Here, I will share a simple step-by-step method to do it-
Step 1: You need to create a block file in your custom module
Step 2: After creating the block file you need to create a template file customfile.phtml path:
Step 3: You need to create a default layout default.xml file path:
Click here to learn about all methods in detail