If you want to use custom php in wordpress then there are some plugins that allow you to write php code.
Here is link of WordPress plugin for PHP
Please download this plugin and install in your WordPress website. When installation is done then activate this plugin.
This will let you allow to write PHP code either in its snippet, you will see WOODY-SNIPPET on dashboard of wordpress from where you can add new snippet and write php code. You new snippet will provide you a code that can be used on any page of wordpress.
Bellow screenshot will explain.
From above screenshot you can add new PHP snippet and write php code , Also you can connect with database and fetch data. All data fetched from DB can be used on home page using code.