So I'm trying to add a few lines of custom PHP code to a site that I am using Magento with. I have some understanding that I would need to create a module and the necessary files and directories but every thing I've has either resulted in a broken page or my result just not showing up at all. I want to be able to create the code as well as maybe call to it in the phtml file I want it to show on, how can I do this? Also here is the code I want to put in:
<?php
$h = date('G'); //set variable $h to the hour of the day
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
if ($h < 7) $img = 'fish.jpg';
else if ($h < 20) $img = 'frogs.jpg';
else $img = 'potatoes.jpg';
//if it's before 7am, use fish image
//if not and it's before 8pm, use frogs
//otherwise, potatoes
?>
if ($h < 7){ $img = 'fish.jpg'; } elseif ($h < 20){ $img = 'frogs.jpg'; } else { $img = 'potatoes.jpg'; }