PHP»ñÈ¡ä¯ÀÀÆ÷ÐÅÏ¢£¨ÈýÖÖ£©
ת×Ô±¾È˸öÈËÍøÕ¾ ¡¾PHP̽·Õß
¡¿£¬»¶Ó¸÷λ·ÃÎÊÕ¾µã£¡
ÔÚʹÓÃPHP»ñÈ¡ä¯ÀÀÆ÷ÐÅϢʱ£¬Í¨³£ÓÐÁ½ÖÖ·½Ê½£º
µÚÒ»ÖÖÊÇ£ºÊ¹ÓÃ$_SERVER[HTTP_USER_AGENT]Ñ¡Ïî
´Ë·½Ê½»ñÈ¡µÄÊǸñʽ²»¹æÔòµÄÊý¾Ý£¬Èç
Mozilla/4.0 (compatible; MSIE 8.0
; Windows NT 5.1; Trident/4.0; GTB6; CIBA; .NET CLR 2.0.50727)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.33
Safari/532.0
¾ßÌåä¯ÀÀÆ÷ÐͺÅÐèÒª×Ô¼º·ÖÎö²ÅÄÜ»ñÈ¡£¬·Ö±ðÊÇ IE8¡¢Firefox/3.5.5¡¢
Chrome/3.0¡£
µÚ¶þÖÖÊÇ£ºÊ¹ÓÃPHPµÄget_browser(£©º¯Êý
ÔÚʹÓô˺¯Êýʱ£¬Ò»°ã»áµÃµ½ÈçϾ¯¸æ
“Warning
: get_browser() [function.get-browser
]: browscap ini directive
not set. in …”
ͨ¹ý²é¿´PHPÊÖ²á¿ÉÒÔÖªµÀ£¬Õâ¸öº¯ÊýµÄʹÓÃÊÇÓÐÌõ¼þµÄ£º
Note
: In order for this to
work, your browscap configuration setting in php.ini
must point to
the correct location of the browscap.ini
file on your
system.
browscap.ini
is not bundled with PHP, but you may find an
up-to-date »
php_browscap.ini
file here.
While browscap.ini
contains
information on many browsers, it relies on user updates to keep the database
current. The format of the file is fairly self-explanatory.
Òâ˼ÊÇ˵£ºÎªÁËʹÓÃÕâ¸öº¯Êý£¬Äã±ØÐëÔÚphp.iniÎļþÀïÃæÔö¼ÓÒ»¾äÖ¸Ïò browscap.ini
ÎļþµÄÅäÖã¬browscap.iniÎļþÀïÃæ¼Ç¼ÁËËùÓÐÒÑ´æÔÚµÄä¯ÀÀÆ÷µÄÀàÐͼ°ÆäÐÅÏ¢£¬
ËùÒÔÄãÒªÏÂÔØ×îеÄÕâ¸öÎļþ£¬ÏÂÔØbrowscap.iniºó·Åµ½·þÎñÆ÷ij¸öλÖã¬get_browser()ÔÚʹÓÃʱ¾ÍÊǽ«»ñÈ¡µÄ¿Í»§¶ËÐÅÏ¢Óë´ËÎļþ½øÐжԱȣ¬Èç¹ûÄÜÕÒµ½£¬Ôò·µ»ØÏàÓ¦ÀàÐÍ¡£
ÕâÑù¿´À´µÚ¶þÖÖ·½Ê½ÓÐЩ¸´ÔÓ£¬ÆäʵҲÓиüºÃµÄ·½Ê½£¬ÄǾÍÊǵÚÈýÖÖ:
µÚÈýÖÖ£ºÊ¹ÓÃÒÑÓеŦÄÜÇ¿´óµÄ¿ªÔ´´úÂë¡£
¹úÍâÓиö½Ðmavrick
µÄ
ÍøÕ¾£¬ÉÏÃæÓйØÓÚä¯ÀÀÆ÷µÄÏîÄ¿£¬Ò»Ö±¸üÐÂËùдµÄBrowser
À࣬ÎÒ×îп´µ½µÄÕâ¸öÀà¿ÉÒÔ»ñÈ¡°üÀ¨iPhone¡¢BlackBerry¡¢win¡¢mac¡¢linux¡¢OS¡¢BeOSµÈƽ̨ÉϵÄä¯ÀÀÆ÷ÐÅÏ¢£¬¹¦ÄÜ¿ÉÒÔ˵ÊÇÊ®·ÖÇ¿´ó¡£ÏÂÔØÕâ¸öÎļþʱҪ¸ù¾Ý×Ô¼ºÊ¹ÓõÄPHP°æ±¾È¥Ñ¡Ôñ¡£
Click here
for an
example.
PHP5
Browser v1.6 Detection Page
PH
Ïà¹ØÎĵµ£º
ƽʱÓà htmlspecialchars() À´¹ýÂËhtml, µ«ÊÇ°ÑhtmlµÄ×Ö·ûתÒåÁË,×îºóÏÔʾ³öÀ´µÄ¾ÍÊÇhtmlÔ´´úÂë, ÀûÓÃstrip_tags()¾Í¿ÉÒÔ°Ñhtml±êÇ©È¥³ýµô.
[php]
$str = 'harryxu
‘;
echo(htmlspecialchars($str) . ‘
‘);
echo(strip_tags($str));
// output:
// harryxu
// harryxu
?>
......
Èç¹ûËùÓеÄClass¶¼Ó¦¸Ã´æÔÚÓÚÒ»¸öĬÈϵIJ㼶ÖеĻ°£¬ÄÇô×²ãÓ¦¸ÃÊÇ×îΪһ°ãµÄClass£¬Ò²¾ÍÊÇ˵¼«Îª³éÏóµÄ£¬Ã¿Ò»¸öϲãµÄClass¾ù±ÈÆäÉϲã
µÄClass£¨¼´¸¸Àࣩ¸ü¼ÓרÃÅ»¯¡£»ùÓÚ¸Ã˼Ï룬ÔÚPHPÖУ¬Õâ¸ö¶¥²ãµÄClass±»ÃüÃûΪ“stdClass”£¬ÇÒ×÷Ϊһ¸ö“Standard
Class”£¬Äã¿ÉÒÔ°ÑËü¿´³ÉÊÇÒ ......
PHP³ÌÐòÔ±µÄÊ®¸ö½¨ÒéÐÔ¼¼ÇÉ
2009-07-11 09:46
Ò»¸öͬÑùµÄ¹¦ÄÜ,¸÷ÖÖ³ÌÐòÓïÑÔ´ó¶àÄÜʵÏÖ.¾ÍËãÒ»ÖÖÓïÑÔ,Ò²ÓкܶàÖÖʵÏÖ·½·¨.¸÷ÖÖ·½·¨¸÷Óи÷µÄºÃ»µ.
¶ÔÓÚPHP
±È½Ï³£¼ûµÄ¼¸¸ö³ÌÐòʹÓÃÎÊÌâ.±¾ÎÄ×ܽáһЩPHP³ÌÐòÔ±µÄÊ®¸ö½¨ÉèÓë¼¼ÇÉ,¹©´ó¼Ò²Î¿¼.
¡¡¡¡1.ʹÓà ip2long() ºÍ ......
Õâ¶Îʱ¼äÔÚ¿´¡¶PHPºÍMySQL Web¿ª·¢¡·Ò»Êé¿´µ½str_replace½²½â£¬Ò»¶ÎСÌáʾдµ½£º¿ÉÒÔΪstr_replaceµÄÈý¸ö¶¼Ê¹ÓÃÊý×é´«È룬µ«½²½â±È½Ï¼òµ¥£¬ÓÚÊǾö¶¨×Ô¼ºµÄÊÔÑéһϸú¯ÊýÔÚ¸÷¸ö²ÎÊý´«ÈëÊý×éʱµÄÖ´Ðнá¹û¡£
º¯ÊýÔÐÍ£ºmixed str_replace(mixed needle,mixed new_needle,mixed haystack[,int &count]);
needle£ ......
<?php
// open database connection
@ $db = new mysqli($host, $user, $password, $database_name);
if (mysql_connect_error())
{
echo '';
exit;
}
// query
$result = $db->query($sql);
$num_results = $db->num_rows;
// data
$row = $result->fetch_assoc(); // row is array, $row['id' ......