Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : php

phpÖ®XMLתÊý×麯Êý

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.
* $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance.
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
* Examples: $array = xml2array(file_get_contents('feed.xml'));
* $array = xml2array(file_get_contents('feed.xml', 1, 'attribute'));
*/
function xml2array($contents, $get_attributes=1, $priority = 'tag') {
if(!$contents) return array();
if(!function_exists('xml_parser_create')) {
//print "'xml_parser_create()' ......

phpÖ®XMLתÊý×麯Êý

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.
* $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance.
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
* Examples: $array = xml2array(file_get_contents('feed.xml'));
* $array = xml2array(file_get_contents('feed.xml', 1, 'attribute'));
*/
function xml2array($contents, $get_attributes=1, $priority = 'tag') {
if(!$contents) return array();
if(!function_exists('xml_parser_create')) {
//print "'xml_parser_create()' ......

PHPµÄ±àдSQLÓï¾äʱ¶ÔÐèҪתÒå×Ö·ûµÄ´¦Àí

1. ¶ÔÓÚPHP magic_quotes_gpc=onµÄÇé¿ö£¬ ÎÒÃÇ¿ÉÒÔ²»¶ÔÊäÈëºÍÊä³öÊý¾Ý¿âµÄ×Ö·û´®Êý¾Ý×÷
addslashes()ºÍstripslashes()µÄ²Ù×÷,Êý¾ÝÒ²»áÕý³£ÏÔʾ¡£ Èç¹û´ËʱÄã¶ÔÊäÈëµÄÊý¾Ý×÷ÁËaddslashes()´¦Àí£¬
ÄÇôÔÚÊä³öµÄʱºò¾Í±ØÐëʹÓÃstripslashes()È¥µô¶àÓàµÄ·´Ð±¸Ü¡£ 2. ¶ÔÓÚPHP magic_quotes_gpc=off µÄÇé¿ö ±ØÐëʹÓÃaddslashes()¶ÔÊäÈëÊý¾Ý½øÐд¦Àí£¬µ«²¢²»ÐèҪʹÓÃstripslashes()¸ñʽ»¯Êä³ö
ÒòΪaddslashes()²¢Î´½«·´Ð±¸ÜÒ»ÆðдÈëÊý¾Ý¿â£¬Ö»ÊǰïÖúmysqlÍê³ÉÁËsqlÓï¾äµÄÖ´ÐС£ ²Î¿¼×ÊÁÏ: <PHP magic_quotes_gpcµÄÏêϸʹÓ÷½·¨> ......

PHPµÄ±àдSQLÓï¾äʱ¶ÔÐèҪתÒå×Ö·ûµÄ´¦Àí

1. ¶ÔÓÚPHP magic_quotes_gpc=onµÄÇé¿ö£¬ ÎÒÃÇ¿ÉÒÔ²»¶ÔÊäÈëºÍÊä³öÊý¾Ý¿âµÄ×Ö·û´®Êý¾Ý×÷
addslashes()ºÍstripslashes()µÄ²Ù×÷,Êý¾ÝÒ²»áÕý³£ÏÔʾ¡£ Èç¹û´ËʱÄã¶ÔÊäÈëµÄÊý¾Ý×÷ÁËaddslashes()´¦Àí£¬
ÄÇôÔÚÊä³öµÄʱºò¾Í±ØÐëʹÓÃstripslashes()È¥µô¶àÓàµÄ·´Ð±¸Ü¡£ 2. ¶ÔÓÚPHP magic_quotes_gpc=off µÄÇé¿ö ±ØÐëʹÓÃaddslashes()¶ÔÊäÈëÊý¾Ý½øÐд¦Àí£¬µ«²¢²»ÐèҪʹÓÃstripslashes()¸ñʽ»¯Êä³ö
ÒòΪaddslashes()²¢Î´½«·´Ð±¸ÜÒ»ÆðдÈëÊý¾Ý¿â£¬Ö»ÊǰïÖúmysqlÍê³ÉÁËsqlÓï¾äµÄÖ´ÐС£ ²Î¿¼×ÊÁÏ: <PHP magic_quotes_gpcµÄÏêϸʹÓ÷½·¨> ......

PHPËæ»úÊýÉú³ÉÓëʹÓýâÎö

ÔÚPHP³ÌÐòÉè¼ÆÖУ¬Ëæ»úÊýµÄÉú³ÉÓÈÎªÖØÒª¡£ÎÒÃÇÐèÒªÓÃËæ»úÊýÔÚÎÒÃǵÄÒ³ÃæÖÐÕ¹Ê¾Ëæ»ú¼Ç¼£¨±ÈÈçͼƬ¡¢Óû§¼Ç¼¡¢ÎÄÕÂIDµÈ£©¡£ÎÒÃÇ»¹¿ÉÒÔʹÓÃËæ»úÊýÉè¼ÆÈκÎÎÒÃÇÏëÏóµÄ³ÌÐò½á¹¹¡£
Ê×ÏÈÀ´ÈÏʶһÏÂPHPÌṩµÄËæ»úÊýº¯Êýrand()¡£PHPµÄrand()º¯Êý½«·µ»ØËæ»úÕûÊý£¬¾ßÌåʹÓ÷½·¨ÈçÏÂ
rand(min,max)
¿ÉÑ¡²ÎÊýminºÍmax¿ÉÒÔʹrand() ·µ»Ø0µ½RAND_MAXÖ®¼äµÄÎ±Ëæ»úÕûÊý¡£ÀýÈ磬ÏëÒª5µ½15£¨°üÀ¨ 5 ºÍ 15£©Ö®¼äµÄËæ»úÊý£¬Óà rand(5, 15)¡£
ÏÂÃæÎÒÀ´¿´Ò»¸ö¾ßÌåµÄʾÀý£¬ÎÒÃÇ×öÒ»¸ö»ù±¾µÄº¯Êýµ÷Ó㬲»ÉèÖþßÌåµÄ²ÎÊý£¬ÎÒÃǵõ½µÄËæ»úÊý½«²»ÊÜminºÍmaxÁ½¸ö²ÎÊýµÄÏÞÖÆ¡£
echo
(rand());?> 
µÃµ½µÄ½á¹û£º652696728 (Ëæ»ú½á¹û)
1¡¢Ê¹ÓÃPHPÉú³ÉÖ¸¶¨Çø¼äÄÚµÄËæ»úÊý
Èç¹ûÎÒÃÇÒªÉú³ÉÁ½¸öÊý×ÖÖ®¼äµÄËæ»úÊý£¬ÎÒÃÇÐèҪΪrandÉ趨Á½¸ö²ÎÊý£º
ÕâÑù£¬ÎÒÃǵõ½µÄ½á¹û¾ÍÔÚÎÒÃǵĿØÖÆÖ®ÖУ¬ËûÓ¦¸ÃÊÇMinNum <= result <= MaxNum£»¼ÙÉèÎÒÃÇҪʹÓÃPHPÉú³É10000µ½2000Ö®¼äµÄËæ»úÊý£¬ÎÒÃǵĴúÂëÓ¦¸ÃÕâÑùд£º
echo
(rand(1000,2000));?> 
¹»¼òµ¥°É£¬ÏÂÃæÀ´µãÉÔ΢ÓÐЩÄѶȵġ£ÔÚ±¾ÎĵĿªÊ¼ÎÒÃÇ˵¹ý£¬Ëæ»úÊýµÄ×÷Óúܴó£¬ÎÒÃÇ¿ÉÒÔÓÃPHPËæ»úÊý½â¾öһЩ¸´ÔÓµÄÎÊÌâ¡£
2¡¢Ê¹ÓÃPHP»ñµÃÒ»¸ö¼¯º ......

25¸öPHPÓÎÏ·±à³Ì½Å±¾´úÂë


±¾ÎĽéÉܵĽű¾Ò×ÓÚÀí½â¡¢Ê¹Óüòµ¥²¢¿ÉÒÔ¿ìËÙÕÆÎÕ¡£
¼òµ¥µÄÖÀ÷»Æ÷
Ðí¶àÓÎÏ·ºÍÓÎϷϵͳ¶¼ÐèÒª÷»×Ó¡£ÈÃÎÒÃÇÏÈ´Ó¼òµ¥µÄ²¿·ÖÈëÊÖ£ºÖÀÒ»¸öÁùÃæ÷»×Ó¡£Êµ¼ÊÉÏ£¬¹ö¶¯Ò»¸öÁùÃæ÷»×Ó¾ÍÊÇ´Ó 1 µ½ 6 Ö®¼äÑ¡ÔñÒ»¸öËæ»úÊý×Ö¡£ÔÚ PHP ÖУ¬ÕâÊ®·Ö¼òµ¥£ºecho rand(1,6);¡£
ÔÚÐí¶àÇé¿öÏ£¬Õâ»ù±¾ÉϺܼòµ¥¡£µ«ÊÇÔÚ´¦Àí»úÂÊÓÎϷʱ£¬ÎÒÃÇÐèҪһЩ¸üºÃµÄʵÏÖ¡£PHP ÌṩÁ˸üºÃµÄËæ»úÊý×ÖÉú³ÉÆ÷£ºmt_rand()¡£ÔÚ²»ÉîÈëÑо¿Á½Õß²î±ðµÄÇé¿öÏ£¬¿ÉÒÔÈÏΪ mt_rand ÊÇÒ»¸ö¸ü¿ì¡¢¸üºÃµÄËæ»úÊý×ÖÉú³ÉÆ÷£ºecho mt_rand(1,6);¡£Èç¹û°Ñ¸ÃËæ»úÊý×ÖÉú³ÉÆ÷·ÅÈ뺯ÊýÖУ¬ÔòЧ¹û»á¸üºÃ¡£
Çåµ¥ 1. ʹÓà mt_rand() Ëæ»úÊý×ÖÉú³ÉÆ÷º¯Êý
¡¡¡¡function roll () {
¡¡¡¡return mt_rand(1,6);
¡¡¡¡}
¡¡¡¡echo roll();
È»ºó¿ÉÒÔ°ÑÐèÒª¹ö¶¯µÄ÷»×ÓÀàÐÍ×÷Ϊ²ÎÊý´«µÝ¸øº¯Êý¡£
Çåµ¥ 2. ½«÷»×ÓÀàÐÍ×÷Ϊ²ÎÊý´«µÝ
¡¡¡¡function roll ($sides) {
¡¡¡¡return mt_rand(1,$sides);
¡¡¡¡}
¡¡¡¡echo roll(6);  // roll a six-sided die
¡¡¡¡echo roll(10);  // roll a ten-sided die
¡¡¡¡echo roll(20);  // roll a twenty-sided die
´ÓÕâÀ↑ʼ£¬ÎÒÃÇ¿ÉÒÔ¼ÌÐø¸ù¾ÝÐèÒªÒ»´Î¹ö¶¯¶à¸ö÷»×Ó£¬·µ»Ø½á¹ûÊý×飻Ҳ¿ÉÒÔ ......

php·ÃÎʳÉÔ±±äÁ¿ºÍ³ÉÔ±·½·¨

php½Ì³Ì:·ÃÎÊPHPÀàÖгÉÔ±±äÁ¿»ò·½·¨
ÔÚ·ÃÎÊPHPÀàÖеijÉÔ±±äÁ¿»ò·½·¨Ê±£¬Èç¹û±»ÒýÓõıäÁ¿»òÕß·½·¨±»ÉùÃ÷³Éconst»òÕßstatic,ÄÇô¾Í±ØÐëʹÓòÙ×÷·û::,
·´Ö®Èç¹û±»ÒýÓõıäÁ¿»òÕß·½·¨Ã»Óб»ÉùÃ÷³Éconst»òÕßstatic,ÄÇô¾Í±ØÐëʹÓòÙ×÷·û->¡£
ÁíÍ⣬Èç¹û´ÓÀàµÄÄÚ²¿·ÃÎÊconst»òÕßstatic±äÁ¿»òÕß·½·¨,ÄÇô¾Í±ØÐëʹÓÃ×ÔÒýÓõÄself£¬
·´Ö®Èç¹û´ÓÀàµÄÄÚ²¿·ÃÎʲ»Îªconst»òÕßstatic±äÁ¿»òÕß·½·¨,ÄÇô¾Í±ØÐëʹÓÃ×ÔÒýÓõÄ$this ......

PHPÃüÁîÐбà³ÌʵÀý£ºFTP+SSL¼òµ¥¿Í»§¶ËʾÀý

ÓÐͬѧÐèҪʹÓÃSSL+FTPµÄ·½Ê½¼ÓÃÜ´«ÊäÎļþ¡£Ï£ÍûÎÒ¸ø·â×°Ò»¸ö¶«Î÷£¬ÐèÇó¾ÍÊÇ¿ÉÒÔÉÏ´«Îļþ£¨PUT£©ºÍÔ¶¶Ë¸ÄÃû£¨RENAME£©¾ÍÐС£
ÎÒ¿ªÊ¼ÒÔΪSSL+FTP = SFTP£¬ºóÀ´·¢ÏÖÕâ¸öÏë·¨ºÃÏñÊÇ´íÎóµÄ¡£SFTPÊÇÅÜÔÚSSHЭÒéÉÏÃæµÄFTP£¬¶øFTPs¾ÍÏñhttpsÒ»ÑùÊÇÅÜÔÚSSLЭÒéÉÏÃæµÄFTP¡£
ʾÀý³ÌÐòʹÓÃÁËftp_ssl_connectº¯Êý¡£Ô´´úÂëÈçÏ£º
#! /bin/php
<?php
if($argc!=8){
echo "Usage:\n";
echo "\t$argv[0] put host port user pass local_file remote_file\n";
echo "\t$argv[0] rename host port user pass old_name new_name\n";
return -1;
}
$host = $argv[2];
$port = $argv[3];
$user = $argv[4];
$pass = $argv[5];
//connect to sftp
$ftps = ftp_ssl_connect($host,$port,10) or die("ERROR:Couldn't connect to $host");
if(@ftp_login($ftps, $user, $pass)){
ftp_pasv($ftps,TRUE);
if($argv[1]== 'put'){
//upload local file
$local_file = $argv[6];
$remote_file = $argv[7];
if(ftp_put($ftps,$remote_file,$local_file,FTP_BINARY)){
echo "PUT Successed.\n";
}else{
......
×ܼǼÊý:2174; ×ÜÒ³Êý:363; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [240] [241] [242] [243] 244 [245] [246] [247] [248] [249]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ