I have 2 PHP files (both’s output are same)
First file code
<?php
function sampleCode()
{
//code here
}
//end function
sampleCode();
?>
Second file code
<?php
//code here
?>
Which is better and less use CPU when I don’t need to recall or include?
If that really is the only difference then in theory version one should be slightly slower, since you have two additional tasks to perform: setting up the function and executing it.
But on modern systems that difference usually is that small, that it is irelevant compared to the load the real code typically creates. So this is more a question to be answered from an architectural point of view, not based on performance comparision.