Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Holiday logo image change using php

Featured Replies

Hello,

 

I am slowly learning how to do more and more with php and integrating it into my sites.

The latest thing I have come up with is to swap the logo on a site depending upon the time of year.

5 logos: a default and then one for Christmas, Easter, valentine and Halloween.

 

It seems to work but I am sure there is a way to make this better. It currently inserts the link into an <img src""/> but all the php is included within the src"" which seems a little untidy! Would I be better to remove this to an external file and have it insert only the relevant link? I am concerned about not only the page looking untidy but also the SEO implications of having all this code at the top of my site.

 

thanks

 

	<?php 	$today = date('Y-m-d');
				$xmasOn = '2010-12-01';
				$xmasOff = '2011-01-06';
				$valentineOn = '2011-02-07';
				$valentineOff = '2011-02-21';
				$easterOn = '2011-04-17'; //easter sunday - April 24
				$easterOff = '2011-05-01';
				$halloweenOn = '2011-10-24';
				$halloweenOff = '2011-11-06';

			if ( ( $today >= $xmasOn ) && ( $today <= $xmasOff ) )
				{echo "images/winking_logo_xmas.gif";}
			elseif ( ( $today >= $valentineOn ) && ( $today <= $valentineOff ) )
				{echo "images/winking_logo_valentine.gif";}
			elseif ( ( $today >= $easterOn ) && ( $today <= $easterOff ) )
				{echo "images/winking_logo_easter.gif";}
			elseif ( ( $today >= $halloweenOn ) && ( $today <= $halloweenOff ) )
				{echo "images/winking_logo_halloween.gif";}
			else {echo "images/winking_logo.gif";}	
	?>

If you want it to look neater in your IDE/editor then store the code in an include file and call that.

 

<img src="<?php include ('dynamic_logo.php');?>" />

 

or store it all at the top of the page and get it to populate a variable instead of echoing the data.

 

<img src="<?=$dynamicLogo?>" />

 

 

Either way there are no SEO implications as your web server will parse the PHP and only output the image string.

  • Author

Ah OK I didn't realise that was the case with SEO implications. The file is already actually a php include file so I might as well leave it where it is!

 

Thanks for the hints.

 

.....still learning :-)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.