Welcome to Hiya Studio For Music Recordings And Website Design

Php To The Rescue!

WordPress / Drag N Drop CMS editors can help even beginners create great sites for sure,  and with all the plugins available there is usually an ‘off the shelf’ solution for ‘advanced website features’, but sometimes a bit of good old fashion coding is needed.


(Php generates the HTML code dynamically at the server end, and has a huge library of functions that can do all sorts of things from database work to advanced string manipulation).


I needed a very simple thing to be done – place 3 images in the header, place a border them, highlighting the active one. 2 of the images linking the current page to the same page on 2 other subdomain sites.


(This was so that i could offer US UK And EU hosting in the respective currencies at the appropriate data centre locations).

You can see the php code in action by clicking the flags in the header of my hosting websites.

Code for hiyahosting.com



$eu = ‘https://eu.’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];

$us = ‘https://us.’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];

$gb = ‘https://’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];

$styledark=” style=”.chr(34).”border:7px solid #5ca2bb”.chr(34);

$stylelight=” style=”.chr(34).”border:7px solid #d0f3ff”.chr(34);

$width=” width=”.chr(34).”45″.chr(34);



echo “<a href=”.$str2.chr(62);

echo “<img src=”.$str.$width.$styledark.chr(62);

echo “</a”.chr(62);



$width=” width=”.chr(34).”49″.chr(34);

echo “<a href=”.$str2.chr(62);

echo “<img src=”.$str.$width.$stylelight.chr(62);

echo “</a”.chr(62);



$width=” width=”.chr(34).”50″.chr(34);

echo “<a href=”.$str2.chr(62);

echo “<img src=”.$str.$width.$styledark.chr(62);

echo “</a”.chr(62);



The code for the subdomains was similar but the sub domain prefix needed stripping out using str_replace() to replace the prefix (eu. / us.) with a null replacement string.



Job done!

Cheers Tony

Leave a Reply