It’s probably too late now, but for anyone else who gets this problem here is what worked for me.
I simply made sure there was no hite spaces before or after the PHP start “<?php” or end “?>” tags e.g. dont have
<?php
function
It should be:
<?php
function