|
 |
12³â Àü |
$data = file("ÆÄÀÏÀ̸§");
À§¿¡Ã³·³ Çϸé ÇØ´çÆÄÀÏÀÇ ¸ðµç ³»¿ëÀÌ $data¶ó´Â º¯¼ö·Î ÀÐÇôÁý´Ï´Ù.
--------- data.txt ÆÄÀÏ ³»¿ë ---------
°¡³ª´Ù¶ó
¸¶¹Ù»ç
¾ÆÀÚÂ÷Ä«
ŸÆÄÇÏ
--------- data.txt ÆÄÀÏ ³»¿ë ---------
data.txt ÆÄÀÏ¿¡´Â 4ÁÙÀÇ ±ÛÀÌ µé¾î°¡ ÀÖ½À´Ï´Ù. ÀÌ ÆÄÀÏÀ» file() ·Î ÀоúÀ»¶§ ¾î¶»°Ô Ç¥½ÃÇÏ¸é µÉ±î¿ä ?
echo $data[0]; ÇϽøé "°¡³ª´Ù¶ó" ¶ó°í Ãâ·ÂµË´Ï´Ù.
echo $data[1]; ÇϽøé "¸¶¹Ù»ç" ¶ó°í Ãâ·ÂµË´Ï´Ù.
echo $data[2]; ÇϽøé "¾ÆÀÚÂ÷Ä«" ¶ó°í Ãâ·ÂµË´Ï´Ù.
echo $data[3]; ÇϽøé "ŸÆÄÇÏ" ¶ó°í Ãâ·ÂµË´Ï´Ù.
2. »õ·Î¿î ÆÄÀÏ »ý¼º ¹× µ¥ÀÌÅÍ ±â·Ï
$file = fopen("data.txt", "w");
fwrite($file, "°¡³ª´Ù¶ó ¸¶¹Ù»ç ¾ÆÀÚÂ÷Ä« ŸÆÄÇÏ");
fclose($file);
À§Ã³·³ ÇϽøé data.txt ¶ó´Â ÆÄÀÏÀ» ¸¸µé¾î¼ ±× ÆÄÀÏ¿¡ "°¡³ª´Ù¶ó ¸¶¹Ù»ç ¾ÆÀÚÂ÷Ä« ŸÆÄÇÏ" ¶ó°í Àû¾î³Ö°Ô µË´Ï´Ù.
3. ±âÁ¸ ÆÄÀÏ¿¡ µ¥ÀÌÅÍ Ãß°¡Çϱâ
$file = fopen("data.txt", "a");
"a" ¿É¼Ç »ç¿ë½Ã ±âÁ¸ µ¥ÀÌÅÍ¿¡ Ãß°¡Çؼ ±â·ÏÇÑ´Ù´Â ÀǹÌÀÔ´Ï´Ù.
$file = fopen("data.txt", "w");
"w" ¿É¼Ç »ç¿ë½Ã »õ·Î ÀÛ¼ºÇÏ´Â °ÍÀ̶ó ±âÁ¸³»¿ëÀÌ ¸ðµÎ Áö¿öÁý´Ï´Ù.
$file = fopen("data.txt", "r");
"r" ¿É¼Ç »ç¿ë½Ã ÀоîµéÀδٴ ÀǹÌÀÔ´Ï´Ù.
|
|
̵̧ : 534 |
̵̧
¸ñ·Ï
|
|