Making a plugin is a good way to add PHP code in to your website as it will let you disabled it if needed.
It is easy to do but your must have access to your websites files using FTP or you can also use wp-file-manager Plugin to add the files.
Created a folder in wp-content/plugins/ give it a name and created a file inside it called "***.php" (replace the *** with the name you want to call the file, then go to plugins on your website and activated the plugin that shows up in the Plugins interface.
Start the plugin with...
Plugin Name: This is the name of my Plugin
Add the PHP code that you want to be in the plugin.