I’m creating a global file to hold items that will be re-used throughout my website. What are the differences between these two lines of code? Is one “better” than the other?
This:
$logo = "img/mainlogo.jpg";
vs this:
function logo() {
echo "img/mainlogo.jpg";
}
Functions are good.
I see that
function logo()is better than$logo.echodoesn’t take much memory, but$logodoes. Even though,function logo()takes something, it will be handled by PHP’s very own garbage collector. You can also use these functions to ensure that you are not misusing the memory allocated.memory_get_peak_usage();memory_get_usage();Explanation:
Source: 7 tips to prevent PHP running out of memory