php ʹÓÃGD¿âÉú³ÉÑéÖ¤Âë
GD¿âÊÇPHP½øÐÐͼÏó²Ù×÷Ò»¸öºÜÇ¿´óµÄ¿â¡£
ÏÈÔÚphp.iniÀïÔö¼ÓÒ»ÐÐÒýÓãºextension=php_gd2.dll
ÖØÆôapache¡£×öÒ»¸ö²âÊÔÒ³ var_dump(gd_info());Êä³öÊý¾Ý±íÃ÷GD¿âÒýÓóɹ¦¡£
±íµ¥auth.html
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>ÑéÖ¤Âë</title>
</head>
<body>
<h1>ÇëÊäÈëÑéÖ¤Âë</h1>
<form action="check_auth.php" method="post">
<input name="auth" type="text">
<img src="auth.php" border="0" />
<input type="submit" value="Ìá½»">
</form>
</body>
</html>
Éú³ÉÑéÖ¤Âë auth.php
<?php
session_start();
header("Content-type:image/png");
$img_width=100;
$img_height=20;
srand(microtime()*100000);
for($i=0;$i<4;$i++)
{
$new_number.=dechex(rand(0,15));
}
$_SESSION[check_auth]=$new_number;
$new_number=imageCreate($img_width,$img_height);//´´½¨Í¼Ïó
ImageColorAllocate($new_number,255,255,255); //ÉèÖñ³¾°É«Îª°×É«
for($i=0;$i<strlen($_SESSION[check_auth]);$i++)
{
$font=mt_rand(3,5);
$x=mt_rand(1,8) + $img_width*$i/4;
$y=mt_rand(1,$img_height/4);
$color=imageColorAllocate($new_number,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));//ÉèÖÃ×Ö·ûÑÕÉ«
imageString($new_number,$font,$x,$y,$_SESSION[check_auth][$i],$color);//Êä³ö×Ö·û
}
ImagePng($new_number);
&nb
Ïà¹ØÎĵµ£º
ÄãÊÇPHP²ËÄñ£¬Èç¹ûÄ㣺
1. ²»»áÀûÓÃÈçphpDoc
ÕâÑùµÄ¹¤¾ßÀ´Ç¡µ±µØ×¢ÊÍÄãµÄ´úÂë
2. ¶ÔÓÅÐãµÄ¼¯³É¿ª·¢»·¾³ÈçZend Studio
»òEclipse PDT
ÊÓ¶ø²»¼û
3. ´ÓδÓùýÈκÎÐÎʽµÄ°æ±¾¿ØÖÆϵͳ£¬ÈçSubclipse
4. ²»²ÉÓÃijÖÖ±àÂëÓëÃüÃû±ê×¼
£¬ÒÔ¼°Í¨ÓÃÔ¼¶¨£¬²»ÄÜÔÚÏîÄ¿¿ª·¢ÖÜÆÚÀï¹á³¹Âäʵ
5. ²»Ê¹ÓÃͳһ¿ª·¢·½Ê½
6. ²»×ª ......
°²×°ÒÔ¼°ÅäÖÃ
1. °²×°Apache-2.2.4(Apache_Dir=D:\myspace\Apache-2.2.4)
2. ½âѹ°²×°PHP-5.2.11(PHP_Dir=D:\myspace\PHP-5.2.11)
3. ÕÒµ½PHP-5.2.11ϵÄphp.ini-dist£¬¸ÄÃûΪphp.ini
4. &nb ......
<?php
//×÷Õß:ÁºÎÄƽ http://www.tyasp.net
session_start();
if($_SESSION["username"]!="admin")
{
echo("<mce:script type="text/javascript"><!--
alert("²Ù×÷³¬Ê±£¡ÇëÖØеǽ...");window.location.href="../index.php";
// --></mce:script>");
//header("refresh:0;url=../"); ......
ÔÚphpÖз¢ËÍÓʼþ¿ÉÒÔÓÃ×Ô´øµÄmail()º¯Êý£¬µ«ÊÇÕâ¸öº¯Êý²»×ãµãºÜÃ÷ÏÔ£¬×îÖ÷ÒªÊÇÔÛ±¾»úÉÏûÓа²×°smtp·þÎñ¾Íû·¨Ê¹ÓÃmail()¡£
µ±È»ÏÖÔÚ»¹ÓÐphpÆäËûµÄ²å¼þ¡¢ÀàʲôµÄ£¬ÄÇЩҲÐí¹¦ÄÜÆëÈ«£¬¿ÉÊÇÍâ¼Ó¾Í¸Ð¾õ²»Ë¬¡£
ÄÇÆäËû°ì·¨µÄ»°£¬Ò»°ã»áÏ뵽ͨ¹ýSMTP·þÎñÆ÷À´·¢ËÍÓʼþ£¬µ«ÊÇÒ²»á²úÉúһϵÁÐÎÊÌ⣨¾ßÌåÓÐÄÄЩÎÊÌâ¿É¼û²Î¿¼×ÊÁÏ"ÎÞÐ ......
1¡¢¹ýÂ˱êÇ©(HTML)£ºstrip_tags()
ÀýÈ磺
<?php
$text = '<?php ?><p>Test paragraph.</p><!-- Comment -
-> <a href=http://topic.csdn.net/u/20090311/09/"#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// ÔÊÐíʹÓÃ<p>ºÍ<a>
echo stri ......