Thursday, February 2, 2012

Statement evaluation in php switch case

$input = 0;
if(@isset($input)) {
switch($input) {
case ($input>=0 && $input <=4):
echo 'Case 1';
break;
case $input == 5:
echo 'Case 2';
break;
}
}

//Output
Expecting o/p: Case 1
But orig o/p: Case 2

So, its advisable to use boolean/strings in the case. If you want to do evaluation go with 'if' and 'elseif' statement

Wednesday, October 20, 2010

Page Loading Screen/Image for all pages Simple HTML

Use this image or image of your own choice Try some animated gif's for rich UI experience



and this HTML

<!-- Display a loading image while the page is loading Author: Hariharan.C-->
<html>
<head>
<meta equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#loadingDiv img{ border: none; }
#loadingDiv{ opacity: 0.8;filter: alpha(opacity = 80); ZOOM: 1}
/** For IE6 enable this

* html #loadingDiv{
background-color: transparent;
background-image: url(blank.gif);
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="overlay.png", sizingMethod="scale");

}*/
</style>
</head>
<body onload="init()">
<div id="loadingDiv" style="position:absolute;width:100%;height:100%;background-color:#777777;display: block; top: 0pt; left: 0pt; "><div style="z-index: 90;position: absolute; z-index: 150; top: 248px; left: 610px;text-align:center"><img src="loading.gif" id="loadingImage" /><br />Loading Page...Please wait</div></div>
<script type="text/javascript">
var loadingDivObj=(document.all);
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
if (ns4)
loadingDivObj=document.loadingDiv;
else if (ns6)
loadingDivObj=document.getElementById("loadingDiv").style;
else if (ie4)
loadingDivObj=document.all.loadingDiv.style;
function init()
{
if(ns4){loadingDivObj.visibility="hidden";}
else if (ns6||ie4) loadingDivObj.display="none";
}
</script>

<!-- Write your HTML Here -->
<!-- Sample HTML -->
<iframe src="http://www.google.com" style="width:auto;height:auto"></iframe>
</body>
</html>


Use this code to display a page loading screen/image. Place the code in the top of the page before loading css/javascript.
 

Followers