how to use 2 index.php file One for mobile and one for desktop

You can create AMP version of your page for mobile devices.
Please check this tutorial: https://amp.dev/documentation/guides-and-tutorials/start/create/basic_markup?format=websites