推薦:解讀php程序生成驗證碼圖片的方法以下為引用的內容:
?php
//生成驗證碼圖片
Header(Content-type: image/PNG);
srand((double)microtime()*1000000);
以下為引用的內容:
<?
arr=getimagesize("images/album_01.gif");
echo arr[3];
strarr=explode("\"",arr[3]);
echo strarr[1];
?>
<HTML>
<HEAD>
<TITLE>演示圖片等比例縮小</TITLE>
<script>
function Wa_SetImgAutoSize(img)
{
//var img=document.all.img1;//獲取圖片
var MaxWidth=200;//設置圖片寬度界限
var MaxHeight=100;//設置圖片高度界限
var HeightWidth=img.offsetHeight/img.offsetWidth;//設置高寬比
var WidthHeight=img.offsetWidth/img.offsetHeight;//設置寬高比
alert("test" img.offsetHeight img.fileSize);
if(img.offsetHeight>1) alert(img.offsetHeight);
if(img.readyState!="complete"){
return false;//確保圖片完全加載
}
if(img.offsetWidth>MaxWidth){
img.width=MaxWidth;
img.height=MaxWidth*HeightWidth;
}
if(img.offsetHeight>MaxHeight){
img.height=MaxHeight;
img.width=MaxHeight*WidthHeight;
}
}
function CheckImg(img)
{
var message="";
var MaxWidth=1;//設置圖片寬度界限
var MaxHeight=1;//設置圖片高度界限
if(img.readyState!="complete"){
return false;//確保圖片完全加載
}
if(img.offsetHeight>MaxHeight) message ="\r高度超額:" img.offsetHeight;
if(img.offsetWidth>MaxWidth) message ="\r寬度超額:" img.offsetWidth;
if(message!="") alert(message);
}
</script>
</HEAD>
<BODY>
<img src="images/frequency.gif" border=0 id="img1" onload="CheckImg(this);">
<br>
<input id=inp type="file" onpropertychange="img1.src=this.value;">
</BODY>
</HTML>
|
分享:淺談PHP中用正則表達式驗證中文的問題str = '中華人民共和國123456789abcdefg';
echo preg_match(/^[u4e00-u9fa5_a-zA-Z0-9]{3,15},strName);
運行一下上面這段代碼,看會有什么提示信息?
Warning: preg_matc