源码

<?php/***QRCode+LogoGeneratorQR图片中间加logo,QR是根据google开放api生成的,其实啥都没有**http://labs.nticompassinc.com*///ini_set("auto_detect_line_endings",true);$data=isset($_GET['data'])?$_GET['data']:'http://weixin.qq.com/r/8bxsY6LEqpzVh7MAn_nV';$size=isset($_GET['size'])?$_GET['size']:'200x200';$logo=isset($_GET['logo'])?$_GET['logo']:'./logo.jpg';//中间那logo图//GetQRCodeimagefromGoogleChartAPI//http://code.google.com/apis/chart/infographics/docs/qr_codes.html//https://chart.googleapis.com/chart?cht=qr&chld=H|1&chs='.$size.'&chl='.urlencode($data));$png="http://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=Hello+world&chld=L|1&choe=UTF-8";$QR=imagecreatefrompng($png);//Warning:imagecreatefrompng()[function.imagecreatefrompng]:Unabletofindthewrapper"https"-didyouforgettoenableitwhenyouconfiguredPHP?=//$QR=imagecreatefrompng('./chart.png');//外面那QR图if($logo!==FALSE){$logo=imagecreatefromstring(file_get_contents($logo));$QR_width=imagesx($QR);$QR_height=imagesy($QR);$logo_width=imagesx($logo);$logo_height=imagesy($logo);//ScalelogotofitintheQRCode$logo_qr_width=$QR_width/5;$scale=$logo_width/$logo_qr_width;$logo_qr_height=$logo_height/$scale;$from_width=($QR_width-$logo_qr_width)/2;//echo$from_width;exit;imagecopyresampled($QR,$logo,$from_width,$from_width,0,0,$logo_qr_width,$logo_qr_height,$logo_width,$logo_height);}header('Content-type:image/png');imagepng($QR);imagedestroy($QR);?>转:http://www.2cto.com/kf/201212/178527.html

2013-4-2 5257 0
软件

示例一:<?php//说明:获取完整URLfunctioncurPageURL(){$pageURL='http';if($_SERVER["HTTPS"]=="on"){$pageURL.="s";}$pageURL.="://";if($_SERVER["SERVER_PORT"]!="80"){$pageURL.=$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];}else{$pageURL.=$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];}return$pageURL;}?>定义该函数之后就可以直接调用了:<?phpechocurPageURL();?>上面的函数可以获取当前页面完整的URL,即你在浏览器地址栏看到的内容。但是,有时候我们不想要URL中的参数(?号后面的内容),如:http://www.hack001.com/hello.html?u=123,只想获取http://www.hack001.com/hello.html,你可以将以上函数做以下更改:示例二:<?php//说明:获取无参数URLfunctioncurPageURL(){$pageURL='http';if($_SERVER["HTTPS"]=="on"){$pageURL.="s";}$pageURL.="://";$this_page=$_SERVER["REQUEST_URI"];//只取?前面的内容if(strpos($this_page,"?")!==false)$this_page=reset(explode("?",$this_page));if($_SERVER["SERVER_PORT"]!="80"){$pageURL.=$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$this_page;}else{$pageURL.=$_SERVER["SERVER_NAME"].$this_page;}return$pageURL;}?>当然也可以采用$_SERVER['PHP_SELF'](该变量不返回URL中的参数),<?php//说明:获取无参数URLfunctioncurPageURL(){$pageURL='http';if($_SERVER["HTTPS"]=="on"){$pageURL.="s";}$pageURL.="://";if($_SERVER["SERVER_PORT"]!="80"){$pageURL.=$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER['PHP_SELF'];}else{$pageURL.=$_SERVER["SERVER_NAME"].$_SERVER['PHP_SELF'];}return$pageURL;}?>另外,$_SERVER['REQUEST_URI']和$_SERVER['REQUEST_URL']是有稍微区别的:$_SERVER["REQUEST_URI"]返回完整的路径(/directory/file.ext?query=string)$_SERVER['REQUEST_URL']只返回文件路径,不包括参数,(/directory/file.ext),和$_SERVER['PHP_SELF']差不多,只不过在有些服务器上$_SERVER['REQUEST_URL']不可用!注意:URL使用rewrite规则的时候,$_SERVER['PHP_SELF']和$_SERVER["REQUEST_URL"]可能不会返回你想要的东西最后提醒一点,$_SERVER["REQUEST_URI"]只有apache才支持,想要一个获取$_SERVER['REQUEST_URI']值的通用解决方案,可以使用以下方案:<?php//说明:获取_SERVER['REQUEST_URI']值的通用解决方案//来源:drupal-5.1bootstrap.inc//整理:http://www.codebit.cn/pub/html/php_mysql/tip/other/request_urifunctionrequest_uri(){if(isset($_SERVER['REQUEST_URI'])){$uri=$_SERVER['REQUEST_URI'];}else{if(isset($_SERVER['argv'])){$uri=$_SERVER['PHP_SELF'].'?'.$_SERVER['argv'][0];}else{$uri=$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];}}return$uri;}?>

2013-4-2 3252 0