Posts Tagged Php
Permanet Redirect in PHP
Posted by in PHP code on August 6th, 2010
<?php
// Permanent redirection
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.website.com/”);
exit();
?>
Find out PHP execution time
Posted by in General on March 11th, 2010
function microtime_float ()
{
list ($msec, $sec) = explode(‘ ‘, microtime());
$microtime = (float)$msec + (float)$sec;
return $microtime;
}
$startdebug = microtime_float();
$end = microtime_float();
echo ‘Script Execution Time: ‘ . round($end – $startdebug, 3) . ‘ seconds’;
Autoscroll with PHP
Posted by in PHP code on October 16th, 2009
Here’s the code for auto scroll with php:
.scrollbar {
height: 70px;
overflow: auto;
width:100px;
}
</style>
<div class=scrollbar>
money <br />
stock<br />
finance<br />
option<br />
forex<br />
currency<br />
loan<br />
Get IP with PHP
Posted by in PHP code on July 12th, 2009
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
else {
$ip = $_SERVER["REMOTE_ADDR"];
}
}
else {
if ( getenv( ‘HTTP_X_FORWARDED_FOR’ ) ) {
$ip = getenv( ‘HTTP_X_FORWARDED_FOR’ );
}
elseif ( getenv( ‘HTTP_CLIENT_IP’ ) ) {
$ip = getenv( ‘HTTP_CLIENT_IP’ );
}
else {
$ip = getenv( ‘REMOTE_ADDR’ );
}
}
return $ip;
}
Cloud Tag at wordpress
Posted by in Wordpress on July 8th, 2009
The syntax for wordpress cloud tag is :
- ‘smallest’
- ‘largest’
- ‘unit’
- ‘number’
- ‘orderby’
<?php wp_tag_cloud(‘smallest=8&largest=22&number=40′); ?>
Set cookie with php
Posted by in PHP code on June 14th, 2009
Here’s the code to set and get cookie
<?php
//set cookie
setcookie(“Cookie1″, $value);
setcookie(“Cookie2″, $value, time()+3600);
//get cookie
echo $_COOKIE["Cookie2"];
?>









