Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PHP»ñÈ¡ÍøÒ³ÄÚÈÝ·½·¨×ܽá

ץȡµ½µÄÄÚÈÝÔÚͨ¹ýÕýÔò±í´ïʽ×öһϹýÂ˾͵õ½ÁËÄãÏëÒªµÄÄÚÈÝ£¬ÖÁÓÚÈçºÎÓÃÕýÔò±í´ïʽ¹ýÂË£¬ÔÚÕâÀï¾Í²»×ö½éÉÜÁË£¬ÓÐÐËȤµÄ£¬ÒÔϾÍÊǼ¸ÖÖ³£ÓõÄÓÃphp×¥È¡ÍøÒ³ÖеÄÄÚÈݵķ½·¨¡£
1.file_get_contents
PHP´úÂë
¸´ÖÆ´úÂë ´úÂëÈçÏÂ:
<?php
$url = "http://www.jb51.net";
$contents = file_get_contents($url);
//Èç¹û³öÏÖÖÐÎÄÂÒÂëʹÓÃÏÂÃæ´úÂë
//$getcontent = iconv("gb2312", "utf-8",$contents);
echo $contents;
?>
2.curl
PHP´úÂë
¸´ÖÆ´úÂë ´úÂëÈçÏÂ:
<?php
$url = "http://www.jb51.net";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//ÔÚÐèÒªÓû§¼ì²âµÄÍøÒ³ÀïÐèÒªÔö¼ÓÏÂÃæÁ½ÐÐ
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
?>
3.fopen->fread->fclose
PHP´úÂë
¸´ÖÆ´úÂë ´úÂëÈçÏÂ:
<?php
$handle = fopen ("http://www.jb51.net", "rb");
$contents = "";
do {
$data = fread($handle, 1024);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while(true);
fclose ($handle);
echo $contents;
?>
×¢£º
1.ʹÓÃfile_get_contentsºÍfopen±ØÐë¿Õ¼ä¿ªÆôallow_url_fopen¡£·½·¨£º±à¼­php.ini£¬ÉèÖÃallow_url_fopen = On£¬allow_url_fopen¹Ø±ÕʱfopenºÍfile_get_contents¶¼²»ÄÜ´ò¿ªÔ¶³ÌÎļþ¡£
2.ʹÓÃcurl±ØÐë¿Õ¼ä¿ªÆôcurl¡£·½·¨£ºwindowsÏÂÐÞ¸Äphp.ini£¬½«extension=php_curl.dllÇ°ÃæµÄ·ÖºÅÈ¥µô£¬¶øÇÒÐèÒª¿½±´ssleay32.dllºÍlibeay32.dllµ½C:\WINDOWS\system32Ï£»LinuxÏÂÒª°²×°curlÀ©Õ¹¡£


Ïà¹ØÎĵµ£º

CentOS+Apache+Mysql+Php°²×°¼°ÓÅ»¯ÅäÖÃС¼Ç


±¾ÎÄÈí¼þµÄÏÂÔØµØÖ·¾Í²»Áгö£¬Ö÷ÒªÊǼǼ°²×°Ê±µÄ²½Öè¼°Ïà¹ØÎÊÌâµÄ´¦Àí·½·¨£»»ùÓÚ°²×°·½·¨Ä¿Ç°ÓÐÁ½ÖÖ£¬Ò»ÖÖÊÇÀûÓÃRPM°ü°²×°£¬Ò»ÖÖÔ´Âë±àÒë°²×°£»ÒÔÏÂÖ÷
ÒªÊÇÒÔÔ´Âë±àÒë°²×°£»ÒòΪԴÂë°²×°Èí¼þµÄÏ໥ÒÀÀµÐÔС£¬°²×°·½Ê½Óø÷ÖÖunix/linuxϵͳ£¬Î¬»¤·½±ã¡£Èç¹ûÏëÈ¥³ýÏà¹Ø·þÎñʱ£¬Ö±½Órm
–rfĿ¼ ¼´¿É£»½¨Òé²ÉÓÃÔ´Âë· ......

php´¦Àíxpath

  1 <?php
  2 $doc = new DOMDocument('1.0', 'utf-8');
  3 $doc->load('./articles.xml');
  4 
  5 $xpath = new DOMXPath($doc);
  6 /*
  7  * $xpath = domxml_open_file("articles.xml");
  8  */
......

Fedora 8ÏÂÓÃYum°²×°Apache+PHP+MySQL»·¾³


fedora8 ÓÃyumÀ´¹ÜÀí°²×°Apache+PHP+MysqlµÄ»ù±¾°²×°¡£
1. °²×°Apahce, PHP, Mysql, ÒÔ¼°phpÁ¬½Ómysql¿â×é¼þ¡£
yum -y install httpd php mysql mysql-server php-mysql
2. ÅäÖÿª»úÆô¶¯·þÎñ
/sbin/chkconfig httpd on             [ÉèÖÃapache·þÎñÆ÷httpd·þÎñ¿ª»úÆô¶¯]
......

PHP´æÈ¡SQL ServerÊý¾Ý¿â

1.Ñ¡Ôñ²Ù×÷µÄÊý¾Ý¿â
Á¬½Óµ½·þÎñÆ÷Ö®ºó£¬Ê×ÏÈÐèҪѡÔñÒª½øÐвÙ×÷µÄÊý¾Ý¿â¡£Ê¹ÓÃPHPµÄMSSQLÀ©Õ¹¿âÖеÄmssql_select_db()º¯Êý¼´¿ÉʵÏÖÁ¬½Ó·þÎñÆ÷ÉϵÄÊý¾Ý¿â¡£¸Ãº¯Êý¸ñʽÈçÏ£º
bool mssql_select_db(string database_name[,resource link_identifier)
¸Ãº¯Êý¸÷²ÎÊýÒâÒ壺
a. ²ÎÊý database_nameΪָ¶¨µÄ·þÎñÆ÷ÉÏ¿ÉÓõÄÊý¾Ý ......

PHP Ïò±íÖÐÌí¼Ó¼Ç¼

Ïò±íÖÐÌí¼Ó¼Ç¼£¬Í¨³£ÒªÊ¹ÓÃÈçϵÄSQLÓï¾ä¡£
INSERT INTO $table_name(field1,field2,field3,......)values('value1','value2','value3'......)
ÆäÖÐ$table_name Ϊָ¶¨µÄ±íÃû£»field1¡¢field2¡¢field3·Ö±ðΪ±íÖÐ×Ö¶ÎÃû£»value1¡¢value2¡¢value3Ôò·Ö±ðΪ×Ö¶Îfield1¡¢field2¡¢field3Ëù¶ÔÓ¦µÄÖµ¡£
ʵÀýÈçºÎÌí¼Óмͼ£º
& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ