PHP to detect mobile phones

The most efficient way to detect mobile phones with PHP, this simply queries the accept headers, the user agent and checks for any tell tale signs that the browser we’re sniffing is a mobile device. Continue reading “PHP to detect mobile phones”

Get current url

<?php
//get the current page URL that is shown in the browser URL window

function curPageURL() {
 $pageURL = ‘http’;
 if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
 $pageURL .= “://”;
 if ($_SERVER["SERVER_PORT"] != “80″) {
  $pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; Continue reading “Get current url”

Php test Navigation engine laguage, and Syetem language

Php test Navigation engine laguage

< ?php echo $_SERVER["HTTP_USER_AGENT"]; ?>

Php test Syetem lang

< ?php echo $_SERVER["HTTP_ACCEPT_LANGUAGE"]; ?>

Continue reading “Php test Navigation engine laguage, and Syetem language”

Show random ads at phpld

If you’re looking for a simple static solution (an not an entire ad manager) use this
add in your init.php after the $tpl = get_tpl(… line Continue reading “Show random ads at phpld”

Make a string’s first character uppercase

ucfirst — Make a string’s first character uppercase

example:

$coo= ‘clay desiccant!’;
$coo= ucfirst($desiccant); // Clay desiccant!

$bar = ‘CLAY DESICCANT!’;
$bar = ucfirst($bar); // CLAY DESICCANT!
$bar = ucfirst(strtolower($bar)); // Clay desiccant!

Continue reading “Make a string’s first character uppercase”

How to ad text on main page of phpld?

{if $category.ID == 0}
This is the description of my homepage. I can even include html.
{/if}

Note:the above code works, but the only problem is this added text also appears when using the search function from the home page. Continue reading “How to ad text on main page of phpld?”

How to show all files under a document and rename the file names?

$dirname=”E:/zhanzhongjie/chengbiao-com/chengbiao-com”;
$dir_handle=opendir($dirname);
while($file=readdir($dir_handle))

{
echo $file.”
“;
rename(“E:/zhanzhongjie/chengbiao-com/chengbiao-com/”. $file, “E:/zhanzhongjie/chengbiao-com/chengbiao-new/insurance-”.$file);
}

closedir($dir_handle) Continue reading “How to show all files under a document and rename the file names?”

Php generate random severeal numbers one time

srand((double)microtime()*1000000);
$random_number1 = rand(1,60);
echo (”$random_number1
“);
$random_number2 = rand(1,60);
echo (”$random_number2
“); Continue reading “Php generate random severeal numbers one time”

Function to judge a character is upper case or lower case

function isLowerCase($char){
if(chr($char)>=97 AND chr($char)< =122)
return true;
else
return false;
} Continue reading “Function to judge a character is upper case or lower case”

Using php to control many domains withing one web host

can build many web sites, with one web host, one site with one different domain, just using php, it can make you very happy, save your money.

$arrays=array(
’www.money.com’=>’money/index.html’,
’www.insurance.com’=>’insurance/index.html’,
’www.car.com’=>’car/index.html’,
’www.travel.com’=>’travel/index.html’,
’127.0.0.1’=>’forum/index.php’,
);
$url = $arrays[$_SERVER[’HTTP_HOST’]];
Header(”Location: $url”);
?> Continue reading “Using php to control many domains withing one web host”