PHP¸ß¼¶Óï·¨£¨Ò»£©—— Îļþ´¦Àí
PHP
Îļþ´¦Àí
fopen()
º¯ÊýÓÃÓÚÔÚ
PHP
Öдò¿ªÎļþ¡£
´ò¿ªÎļþ
fopen()
º¯ÊýÓÃÓÚÔÚ
PHP
Öдò¿ªÎļþ¡£
´Ëº¯ÊýµÄµÚÒ»¸ö²ÎÊýº¬ÓÐÒª´ò¿ªµÄÎļþµÄÃû³Æ£¬µÚ¶þ¸ö²ÎÊý¹æ¶¨ÁËʹÓÃÄÄÖÖģʽÀ´´ò¿ªÎļþ£º
<html>
<body>
<?php
$file=fopen("welcome.txt","r");
?>
</body>
</html>
Îļþ¿ÉÄÜͨ¹ýÏÂÁÐģʽÀ´´ò¿ª£º
ģʽ
ÃèÊö
r
Ö»¶Á¡£ÔÚÎļþµÄ¿ªÍ·¿ªÊ¼¡£
r+
¶Á
/
д¡£ÔÚÎļþµÄ¿ªÍ·¿ªÊ¼¡£
w
ֻд¡£´ò¿ª²¢Çå¿ÕÎļþµÄÄÚÈÝ£»Èç¹ûÎļþ²»´æÔÚ£¬Ôò´´½¨ÐÂÎļþ¡£
w+
¶Á
/
д¡£´ò¿ª²¢Çå¿ÕÎļþµÄÄÚÈÝ£»Èç¹ûÎļþ²»´æÔÚ£¬Ôò´´½¨ÐÂÎļþ¡£
a
×·¼Ó¡£´ò¿ª²¢ÏòÎļþÎļþµÄÄ©¶Ë½øÐÐд²Ù×÷£¬Èç¹ûÎļþ²»´æÔÚ£¬Ôò´´½¨ÐÂÎļþ¡£
a+
¶Á
/
×·¼Ó¡£Í¨¹ýÏòÎļþÄ©¶ËдÄÚÈÝ£¬À´±£³ÖÎļþÄÚÈÝ¡£
x
ֻд¡£´´½¨ÐÂÎļþ¡£Èç¹ûÎļþÒÔ´æÔÚ£¬Ôò·µ»Ø
FALSE
¡£
x+
¶Á
/
д¡£´´½¨ÐÂÎļþ¡£Èç¹ûÎļþÒÑ´æÔÚ£¬Ôò·µ»Ø
FALSE
ºÍÒ»¸ö´íÎó¡£
×¢ÊÍ£ºÈç¹û
fopen()
ÎÞ·¨´ò¿ªÖ¸¶¨Îļþ£¬Ôò·µ»Ø
0 (false)
¡£
Àý×Ó
Èç¹û
fopen()
²»ÄÜ´ò¿ªÖ¸¶¨µÄÎļþ£¬ÏÂÃæµÄÀý×Ó»áÉú³ÉÒ»¶ÎÏûÏ¢£º
<html>
<body>
<?php
$file=fopen("welcome.txt","r")
or exit("Unable to open file!");
?>
</body>
</html>
¹Ø±ÕÎļþ
fclose()
º¯ÊýÓÃÓڹرմò¿ªµÄÎļþ¡£
<?php
$file
= fopen("test.txt","r");
//some
code to be executed
fclose($file);
?>
¼ì²â
End-of-file
feof()
º¯Êý¼ì²âÊÇ·ñÒÑ´ïµ½ÎļþµÄÄ©¶Ë
(EOF)
¡£
ÔÚÑ»·±éÀúδ֪³¤¶ÈµÄÊý¾Ýʱ£¬
feof()
º¯ÊýºÜÓÐÓá£
×¢ÊÍ£º
ÔÚ
w
¡¢
a
ÒÔ¼°
x
ģʽ£¬ÄúÎÞ·¨¶ÁÈ¡´ò¿ªµÄÎļþ£¡
if
(feof($file)) echo "End of file";
ÖðÐжÁÈ¡Îļþ
fgets()
º¯ÊýÓÃÓÚ´ÓÎļþÖÐÖðÐжÁÈ¡Îļþ¡£
×¢ÊÍ£º
ÔÚµ÷Óøú¯ÊýÖ®ºó£¬ÎļþÖ¸Õë»áÒƶ¯µ½ÏÂÒ»ÐС£
Àý×Ó
ÏÂÃæµÄÀý×ÓÖðÐжÁÈ¡Îļþ£¬Ö±µ½ÎļþÄ©¶ËΪֹ£º
<?php
$file
= fopen("welcome.txt", "r") or exit("Unable to open
file!");
//Output
a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
Ïà¹ØÎĵµ£º
<?php
/**
* »ñȡͼÏóÐÅÏ¢µÄº¯Êý
*
* Ò»¸öÈ«Ãæ»ñȡͼÏóÐÅÏ¢µÄº¯Êý
*
* @access public
* @param string $img ͼƬ·¾¶
* @return array
*/
function GetImageInfoVal($ImageInfo,$val_arr) {
$InfoVal = "δ֪";
foreach($val_arr as $name=>$val) {
  ......
phpÒýÓÃ(&)Ïê½â
2009-05-13 14:30
phpµÄÒýÓ㨾ÍÊÇÔÚ±äÁ¿»òÕߺ¯Êý¡¢¶ÔÏóµÈÇ°Ãæ¼ÓÉÏ&·ûºÅ£©
ÔÚPHP ÖÐÒýÓõÄÒâ˼ÊÇ£º²»Í¬µÄÃû×Ö·ÃÎÊͬһ¸ö±äÁ¿ÄÚÈÝ.
Óë£ÃÓïÑÔÖеÄÖ¸ÕëÊÇÓвî±ðµÄ£®£ÃÓïÑÔÖеÄÖ¸ÕëÀïÃæ´æ´¢µÄÊDZäÁ¿µÄÄÚÈÝÔÚÄÚ´æÖдæ·ÅµÄµØÖ·
±äÁ¿µÄÒýÓÃ
PHP µÄÒýÓÃÔÊÐíÄãÓ ......
Zend_Search_Lucene ÊÇÒ»¸öÍêÈ«ÓÉ PHP 5 ±àдµÄͨÓÃÎı¾ËÑË÷ÒýÇæ¡£ÓÉÓÚÆ佫Ë÷Òý±£´æÔÚÎļþϵͳÖжø²»ÐèÒªÊý¾Ý¿âÖ§³Ö£¬Òò´ËËü¼¸ºõ¿ÉÒÔΪÈκÎÓÉ PHP Çý¶¯µÄÍøÕ¾Ôö¼ÓËÑË÷ÄÜÁ¦¡£Zend_Search_Lucene Ö§³ÖÏÂÁÐÌØÐÔ£º
¾ßÓÐÅÅÃû¹¦ÄܵÄËÑË÷——×î·ûºÏÒªÇóµÄ½á¹û³öÏÖÔÚ×îÇ°Ãæ
Ðí¶àÇ¿´óµÄ²éѯÀàÐÍ£º¶ÌÓï²éѯ¡¢Í¨Åä·û²éѯ ......
Ñ»·Óï¾ä
ÔÚÄú±àд´úÂëʱ£¬Äú¾³£ÐèÒªÈÃÏàͬµÄ´úÂë¿éÔËÐкܶà´Î¡£Äú¿ÉÒÔÔÚ´úÂëÖÐʹÓÃÑ»·Óï¾äÀ´Íê³ÉÕâ¸öÈÎÎñ¡£
ÔÚ PHP ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁÐÑ»·Óï¾ä£º
while
Ö»ÒªÖ¸¶¨µÄÌõ¼þ³ÉÁ¢£¬ÔòÑ»·Ö´ÐдúÂë¿é
do...while
Ê×ÏÈÖ´ÐÐÒ»´Î´úÂë¿é£¬È»ºóÔÚÖ¸¶¨µÄÌõ¼þ³ÉÁ¢Ê±Öظ´Õâ¸öÑ»·
for
Ñ»·Ö´ÐдúÂë¿éÖ¸¶¨µÄ´ÎÊý
foreach
¸ù ......