PHP Îļþ¶Áд²Ù×÷
¡¡¡¡PHP ÖУ¬Êý¾Ýͨ³£¶¼ÊÇ´æ´¢ÔÚMySQLÊý¾Ý¿âµ±Öеġ£µ«ÊÇÓÐЩʱºò£¬ÎÒÃÇ»¹ÊÇÐèҪʹÓÃPHP¶ÁдһЩ±¾µØÎļþ¡£±ÈÈçÉú³É¾²Ì¬Ò³Ãæ»òÕßÊý¾ÝµÄ±¾µØ»º´æ¡£
¡¡¡¡PHP5+ ÌṩÁËÒ»ÖÖ·½·¨ file_put_contents(file,data,mode,context)£¬Ëü½«Ò»¸ö×Ö·û´®Ð´ÈëÎļþ£¬·µ»ØдÈëµ½ÎļþÄÚÊý¾ÝµÄ×Ö½ÚÊý¡£ºÍÒÀ´Îµ÷Óà fopen()£¬fwrite() ÒÔ¼° fclose() ¹¦ÄÜÒ»Ñù£¬·½±ãÁËʹÓá£
²ÎÊýÃèÊö
file
±ØÐè¡£¹æ¶¨ÒªÐ´ÈëÊý¾ÝµÄÎļþ¡£Èç¹ûÎļþ²»´æÔÚ£¬Ôò´´½¨Ò»¸öÐÂÎļþ¡£
data
¿ÉÑ¡¡£¹æ¶¨ÒªÐ´ÈëÎļþµÄÊý¾Ý¡£¿ÉÒÔÊÇ×Ö·û´®¡¢Êý×é»òÊý¾ÝÁ÷¡£
mode
¿ÉÑ¡¡£¹æ¶¨ÈçºÎ´ò¿ª/дÈëÎļþ¡£¿ÉÄܵÄÖµ£º
FILE_USE_INCLUDE_PATH£ºÊ¹Óðüº¬Ä¿Â¼¶¨Òå
FILE_APPEND£º×·¼Ó£¬·ÀÖ¹±»¸ÄдÔÎļþÄÚÈÝ
LOCK_EX£º¶ÀÕ¼Ëø¶¨·½Ê½
Èç¹û²ÎÊýÊ¡ÂÔÔòĬÈÏΪ¸ÄдÎļþ·½Ê½
context
¿ÉÑ¡¡£¹æ¶¨Îļþ¾ä±úµÄ»·¾³¡£
context ÊÇÒ»Ì׿ÉÒÔÐÞ¸ÄÁ÷µÄÐÐΪµÄÑ¡Ïî¡£
¡¡¡¡PHP ²Î¿¼ÊéÖУ¬Ö¸Ã÷Á˶ÁÎļþ·½·¨ file_get_contents µÄ¿ÉÓð汾 (PHP 4 >= 4.3.0, PHP 5)£¬PHP 5 ½øÐÐÁËÀ©Õ¹£¬ 5.0.0 Ìí¼ÓÁË¶Ô context µÄÖ§³Ö¡£ 5.1.0 Ìí¼ÓÁË offset ºÍ maxlen ²ÎÊý¡£
¡¡¡¡¾ßÌåÓ÷¨£ºfile_get_contents ( file , flags , context , offset , maxlen)
²ÎÊýÃèÊö
file
±ØÐè¡£¹æ¶¨ÒªÐ´ÈëÊý¾ÝµÄÎļþ¡£Èç¹ûÎļþ²»´æÔÚ£¬Ôò´´½¨Ò»¸öÐÂÎļþ¡£
flags
¿ÉÑ¡¡£¹æ¶¨ÈçºÎ¶ÁÈ¡Îļþ¡£¿ÉÄܵÄÖµ£º
FILE_USE_INCLUDE_PATH£ºÊ¹Óðüº¬Ä¿Â¼¶¨Òå
FILE_TEXT£ºÎı¾¸ñʽÄÚÈÝ¡£
FILE_BINARY£º½öÓÃÓÚ¶þ½øÖƸñʽ¡£
Èç¹û²ÎÊýÊ¡ÂÔÔòĬÈÏΪFILE_BINARY
context
ÉÏÏÂÎÄ
offset
¿ÉÑ¡¡£Æðʼ¶ÁλÖã¬Æ«ÒÆ¡£
maxlen
¿ÉÑ¡¡£¶ÁÈ볤¶È¡£
¡¡¡¡PHP5ÒÔÏ°汾ÎÒÃÇÓà fopen, fread, fwrite, fclose ½øÐÐÎļþ¶Áд¡£ÏÂÃ渽ÉÏÒ»¶ÎÀý×Ó£º
¡¡¡¡Ã¿µ±ÎÒÃÇ·ÃÎÊ´ËÍøÒ³µÄʱºò£¬»áÏÔʾ³ö·ÃÎʹýµÄIPÒÔ¼°·ÃÎÊʱ¼ä£»Í¬Ê±µ±Ç°µÄ·ÃÎÊÒ²»á±»¼Ç¼£¬ÒÔ±ãÔÚÏ´ηÃÎʵÄʱºò³öÏÖ¡£
<?php
header("Content-Type: text/plain");
$visitorIP = $_SERVER["REMOTE_ADDR"];
$currentTime = date("H:i:s");
if( file_exists("./visitLog.log") ):
$logFileHandle = fopen("./visitLog.log", "r+");
$logFileSize = filesize("./visitLog.log");
$logContent = fread($logFileHandle, $logFileSize);
else:
$logFileHandle = fopen("./visitLog.log", "x+");
$logContent = "\r\tNo more Log";
endif;
echo "Visit Lo
Ïà¹ØÎĵµ£º
Ä¿Ç°LAMP (Linux + Apache + MySQL + PHPspan style="font-family: Verdana;">) ½ü¼¸ÄêÀ´·¢Õ¹Ñ¸ËÙ£¬ÒѾ³ÉΪWeb ·þÎñÆ÷µÄÊÂʵ±ê×¼¡£LAMPÕâ¸ö´ÊµÄÓÉÀ´×îÔçʼÓڵ¹úÔÓÖ¾“c't Mag
azine”£¬Michael KunzeÔÚ1990Äê×îÏÈ°ÑÕâЩÏîÄ¿×éºÏÔÚÒ»Æð´´ÔìÁËLAMPµÄËõд×Ö¡£ÕâЩ×é¼þËäÈ»²¢²»ÊÇ¿ª¿ªÊ¼¾ÍÉè¼ÆΪһÆðʹ ......
×Ö·û´®±äÁ¿ÓÃÓÚ´æ´¢²¢´¦ÀíÎı¾Æ¬¶Î¡£
PHP ÖеÄ×Ö·û´®
×Ö·û´®±äÁ¿ÓÃÓÚ°üº¬×Ö·û´®µÄÖµ¡£
ÔÚ±¾½Ì³ÌÖУ¬ÎÒÃÇ´òËã½éÉܼ¸¸öÔÚ PHP ÖÐÓÃÓÚ²Ù×÷×Ö·û´®µÄ×î³£Óõĺ¯ÊýºÍÔËËã·û¡£
ÔÚ´´½¨×Ö·û´®Ö®ºó£¬ÎÒÃǾͿÉÒÔ¶ÔËü½øÐвÙ×÷ÁË¡£Äú¿ÉÒÔÖ±½ÓÔÚº¯ÊýÖÐʹÓÃ×Ö·û´®£¬»òÕß°ÑËü´æ´¢ÔÚ±äÁ¿ÖС£
ÔÚÏÂÃ棬PHP ½Å±¾°Ñ×Ö·û´® "Hello World" ¸³ ......
Èç¹ûÄúʹÓùý PHP£¬Äú¾Í»á·¢ÏÖËüÊÇ´´½¨ÌØÐԷḻµÄ Web Ò³ÃæµÄ³öÉ«¹¤¾ß¡£×÷Ϊһ´ó½Å±¾ÓïÑÔ£¬PHP£º
ÈÝÒ×ѧϰ¡£
ÓÐÐí¶àÇ¿´óµÄ¿ò¼Ü£¨±ÈÈç CakePHP ºÍ CodeIgniter£©£¬ÈÃÄúÄܹ»Ïñ Rails ³ÌÐòÔ±Ò»Ñù¸ßЧ¡£
Äܹ»Óë MySQL¡¢PostgreSQL¡¢Microsoft® SQL Server£¬ÉõÖÁ Oracle ͨÐÅ¡£
Äܹ»ÇáËɵØÓë JavaScript ¿ò¼Ü¼¯³É£¬±È ......
ÔÚÌá¼°°²È«ÐÔÎÊÌâʱ£¬ÐèҪעÒ⣬³ýÁËʵ¼ÊµÄƽ̨ºÍ²Ù×÷ϵͳ°²È«ÐÔÎÊÌâÖ®Í⣬Äú»¹ÐèҪȷ±£±àд°²È«µÄÓ¦ÓóÌÐò¡£ÔÚ±àд PHP Ó¦ÓóÌÐòʱ£¬ÇëÓ¦ÓÃÏÂÃæµÄÆ߸öÏ°¹ßÒÔÈ·±£Ó¦ÓóÌÐò¾ßÓÐ×îºÃµÄ°²È«ÐÔ£º
ÑéÖ¤ÊäÈë
±£»¤Îļþϵͳ
±£»¤Êý¾Ý¿â
±£»¤»á»°Êý¾Ý
±£»¤¿çÕ¾µã½Å±¾£¨Cross-site scripting£¬XSS£©Â©¶´
¼ìÑé±íµ¥ post
Õ ......