# fopen() ํจ์
PHP๋ฅผ ๊ณต๋ถํ๋ ์ค ํ์ผ์ ์ ์ดํ ์ผ์ด ์๊ฒผ๋ค.
C์ธ์ด์์ file์ ๋ค๋ฃจ๋ ๊ฒ๊ณผ ๊ฑฐ์ ๋๊ฐ์ด fopen()๋ฅผ ํ์ฉํ๋ฉด ๋ ์ฌ์ด file ์ ์ด๊ฐ ๊ฐ๋ฅํ๋ค.
C์ธ์ด๋ฅผ ์ฌ์ฉํ ๋ ์์ฃผ ํท๊ฐ๋ ธ๋ r / w / r+ / w+ / a ์ต์ ์ ์ ๋ฆฌํด๋๋ ค๊ณ ํ๋ค.
stack overflow (opens new window) ์ ๋์ ๊ฐ์ ๊ณ ๋ฏผ์ ํ ๊ฐ๋ฐ์์ ์ง๋ฌธ์ ์ธ์ฉํ๊ฒ ๋ค.
# Difference between r+ and w+ in fopen()
In fopen("myfile", "r+")
what is the difference between the "r+"
and "w+"
open mode? I read this
"r"
Open a text file for reading.
"w"
Open a text file for writing, truncating an an existing file to zero length, or creating the file if it does not exist.
"r+"
Open a text file for update (that is, for both reading and writing).
"w+" Open a text file for update (reading and writing), first truncating the file to zero length if it exists or creating the file if it does not exist.
I mean the difference is that if I open the file with "w+", the file will be erased first?
๋ต๋ณ ์ค ์ด ์ด๋ฏธ์ง๋ฅผ ์ฐธ๊ณ ํ๋ฉด ํ์คํ ์ ๋ฆฌ๊ฐ ๋๋ค.