SlideShare a Scribd company logo
This function is similar to file(), except that file_get_contents() returns the
file in a string, starting at the specified offset up to maxlen bytes. On
failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.This function is similar to file(), except that file_get_contents()
returns the file in a string, starting at the specified offset up to maxlen
bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a
string. It will use memory mapping techniques if supported by your OS to enhance
performance.
fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this fopen
The fopen function creates the connection to the file. I say "creates the
connection" because in addition to opening a file, fopen can open a URL:
$fh = fopen("http://127.0.0.1/", "r");
This line of code creates a connection to the page above and allows you to start
reading it much like a local file.
Note: The "r" used in fopen indicates that the file is open for reading only.
Because writing to files is beyond the scope of this article, I'm not going to
list all the other options. However, you should change "r" to "rb" if you're
reading from binary files for cross-platform compatibility. You'll see an
example of this later.
feof
The feof command detects whether you have already read to the end of the file
and returns True or False. The loop in Listing 1 continues until you have
reached the end of the file "myfile." Note that feof also returns False if
you're reading a URL and the socket has timed out because you no longer have
data to read.
fclose
Skipping ahead to the end of Listing 1, fclose serves the opposite function of
fopen: It closes the connection to the file or URL. You are no longer able to
read from the file or socket after this function.
fgets
Learn more. Develop more. Connect more.
The new developerWorks Premium membership program provides an all-access pass to
powerful development tools and resources, including 500 top technical titles
(dozens specifically for open source developers) through Safari Books Online,
deep discounts on premier developer events, video replays of recent O'Reilly
conferences, and more. Sign up today.
Jumping back a few lines in Listing 1, you get to the heart of file processing:
actually reading the file. The fgets function is your weapon of choice for this
first example. It grabs a single line of data from your file and returns it as a
string. From there, you can print or otherwise process your data. The example in
Listing 1 nicely prints out an entire file.
If you decide to limit the size of the data chunks that you'll deal with, you
can add an argument to fgets to limit the maximum line length. For example, use
this

More Related Content

What's hot

Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsing
Felix Z. Hoffmann
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
Lifna C.S
 
File handling in C
File handling in CFile handling in C
File handling in C
Rabin BK
 
File handling in c
File handling in c File handling in c
File handling in c
Vikash Dhal
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
Hitesh Kumar
 
File operations in c
File operations in cFile operations in c
Understanding c file handling functions with examples
Understanding c file handling functions with examplesUnderstanding c file handling functions with examples
Understanding c file handling functions with examples
Muhammed Thanveer M
 
Mashups MAX 360|MAX 2008 Unconference
Mashups MAX 360|MAX 2008 UnconferenceMashups MAX 360|MAX 2008 Unconference
Mashups MAX 360|MAX 2008 Unconference
Elad Elrom
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
Kumar
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...
Edureka!
 
File handling in c
File handling in cFile handling in c
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
ٖFaiXy :)
 
File in c
File in cFile in c
File in c
Prabhu Govind
 
Introduction to the core.ns application framework
Introduction to the core.ns application frameworkIntroduction to the core.ns application framework
Introduction to the core.ns application framework
Vladimir Ulogov
 
File Handling In C++
File Handling In C++File Handling In C++
File handling in c
File  handling in cFile  handling in c
File handling in c
thirumalaikumar3
 
File handling in c
File handling in cFile handling in c
File handling in c
mohit biswal
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
ProfSonaliGholveDoif
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
Vineeta Garg
 
File Handling in C++
File Handling in C++File Handling in C++

What's hot (20)

Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsing
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in python
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File handling in c
File handling in c File handling in c
File handling in c
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
 
File operations in c
File operations in cFile operations in c
File operations in c
 
Understanding c file handling functions with examples
Understanding c file handling functions with examplesUnderstanding c file handling functions with examples
Understanding c file handling functions with examples
 
Mashups MAX 360|MAX 2008 Unconference
Mashups MAX 360|MAX 2008 UnconferenceMashups MAX 360|MAX 2008 Unconference
Mashups MAX 360|MAX 2008 Unconference
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
 
File in c
File in cFile in c
File in c
 
Introduction to the core.ns application framework
Introduction to the core.ns application frameworkIntroduction to the core.ns application framework
Introduction to the core.ns application framework
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 

Viewers also liked

Elaine Martins Santificação
Elaine Martins SantificaçãoElaine Martins Santificação
Elaine Martins Santificação
Lucas Oliveira
 
Curriculum Vitae of Sean Duncan
Curriculum Vitae of Sean DuncanCurriculum Vitae of Sean Duncan
Curriculum Vitae of Sean Duncan
Sean Duncan
 
Clases de inglés in company
Clases de inglés in companyClases de inglés in company
Clases de inglés in company
Giovanna Mussini
 
Windmill14jan16 darryl2
Windmill14jan16 darryl2Windmill14jan16 darryl2
Windmill14jan16 darryl2
Mueller Darryl
 
Curriculum Vitae Hwanman Park 061316
Curriculum Vitae Hwanman Park 061316Curriculum Vitae Hwanman Park 061316
Curriculum Vitae Hwanman Park 061316
Hwanman Park
 
Evaluation Question 5
Evaluation Question 5 Evaluation Question 5
Evaluation Question 5
Katie Bunn
 
American Denial
American DenialAmerican Denial
American Denial
Randi Hovey
 
Statistical Analysis of Social Attitudes
Statistical Analysis of Social AttitudesStatistical Analysis of Social Attitudes
Statistical Analysis of Social Attitudes
Randi Hovey
 
Fuente de poder
Fuente de poderFuente de poder
Abc derecho minero
Abc derecho mineroAbc derecho minero
Abc derecho minero
layfu_2016
 
Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015
Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015
Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015Dianne Huiberts
 
Effects of Divorce on Children as a Function of Age, Sex, and Parenting
Effects of Divorce on Children as a Function of Age, Sex, and ParentingEffects of Divorce on Children as a Function of Age, Sex, and Parenting
Effects of Divorce on Children as a Function of Age, Sex, and Parenting
Randi Hovey
 
Gabinete y memorias extraibles
Gabinete y memorias extraiblesGabinete y memorias extraibles
Gabinete y memorias extraibles
Amairany Guadalupe Hernandez Resendiz
 
Enclave: A Book By Ann Aguirre
Enclave:  A Book By Ann AguirreEnclave:  A Book By Ann Aguirre
Enclave: A Book By Ann Aguirre
Alta Sprague
 
Windmill14jan16 susan2
Windmill14jan16 susan2Windmill14jan16 susan2
Windmill14jan16 susan2
Mueller Darryl
 
OutdoorHDTV Booklet small
OutdoorHDTV Booklet smallOutdoorHDTV Booklet small
OutdoorHDTV Booklet small
Benjamin G. Chapman
 
Mike Messinger Detailed 1_2017
Mike Messinger Detailed 1_2017Mike Messinger Detailed 1_2017
Mike Messinger Detailed 1_2017
Mike Messinger
 
Z-Scope*7
Z-Scope*7Z-Scope*7
Z-Scope*7
Minh-Quang LÊ
 
DisneyCase
DisneyCaseDisneyCase
DisneyCase
Jaya Moolchandani
 
205_55
205_55205_55
205_55
leslern lang
 

Viewers also liked (20)

Elaine Martins Santificação
Elaine Martins SantificaçãoElaine Martins Santificação
Elaine Martins Santificação
 
Curriculum Vitae of Sean Duncan
Curriculum Vitae of Sean DuncanCurriculum Vitae of Sean Duncan
Curriculum Vitae of Sean Duncan
 
Clases de inglés in company
Clases de inglés in companyClases de inglés in company
Clases de inglés in company
 
Windmill14jan16 darryl2
Windmill14jan16 darryl2Windmill14jan16 darryl2
Windmill14jan16 darryl2
 
Curriculum Vitae Hwanman Park 061316
Curriculum Vitae Hwanman Park 061316Curriculum Vitae Hwanman Park 061316
Curriculum Vitae Hwanman Park 061316
 
Evaluation Question 5
Evaluation Question 5 Evaluation Question 5
Evaluation Question 5
 
American Denial
American DenialAmerican Denial
American Denial
 
Statistical Analysis of Social Attitudes
Statistical Analysis of Social AttitudesStatistical Analysis of Social Attitudes
Statistical Analysis of Social Attitudes
 
Fuente de poder
Fuente de poderFuente de poder
Fuente de poder
 
Abc derecho minero
Abc derecho mineroAbc derecho minero
Abc derecho minero
 
Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015
Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015
Dura Vermeer Divisie Infra - Fietsportfolio - oktober 2015
 
Effects of Divorce on Children as a Function of Age, Sex, and Parenting
Effects of Divorce on Children as a Function of Age, Sex, and ParentingEffects of Divorce on Children as a Function of Age, Sex, and Parenting
Effects of Divorce on Children as a Function of Age, Sex, and Parenting
 
Gabinete y memorias extraibles
Gabinete y memorias extraiblesGabinete y memorias extraibles
Gabinete y memorias extraibles
 
Enclave: A Book By Ann Aguirre
Enclave:  A Book By Ann AguirreEnclave:  A Book By Ann Aguirre
Enclave: A Book By Ann Aguirre
 
Windmill14jan16 susan2
Windmill14jan16 susan2Windmill14jan16 susan2
Windmill14jan16 susan2
 
OutdoorHDTV Booklet small
OutdoorHDTV Booklet smallOutdoorHDTV Booklet small
OutdoorHDTV Booklet small
 
Mike Messinger Detailed 1_2017
Mike Messinger Detailed 1_2017Mike Messinger Detailed 1_2017
Mike Messinger Detailed 1_2017
 
Z-Scope*7
Z-Scope*7Z-Scope*7
Z-Scope*7
 
DisneyCase
DisneyCaseDisneyCase
DisneyCase
 
205_55
205_55205_55
205_55
 

Similar to Book

FILES IN C
FILES IN CFILES IN C
FILES IN C
yndaravind
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
Mehul Desai
 
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
vsol7206
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptx
AssadLeo1
 
Php files
Php filesPhp files
Php files
kalyani66
 
Files in PHP.pptx g
Files in PHP.pptx                      gFiles in PHP.pptx                      g
Files in PHP.pptx g
FiromsaDine
 
File handling in Python
File handling in PythonFile handling in Python
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
Gheyath M. Othman
 
4 text file
4 text file4 text file
4 text file
hasan Mohammad
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdf
RashmiAngane1
 
Python file handlings
Python file handlingsPython file handlings
Python file handlings
22261A1201ABDULMUQTA
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
Techglyphs
 
Satz1
Satz1Satz1
Satz1
rajeshmhvr
 
File handling C program
File handling C programFile handling C program
File handling C program
Thesis Scientist Private Limited
 
Module 5 file cp
Module 5 file cpModule 5 file cp
Module 5 file cp
Amarjith C K
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
keeeerty
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
Keerty Smile
 
Files nts
Files ntsFiles nts
Files nts
kalyani66
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
mussawir20
 
File Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptFile Handling as 08032021 (1).ppt
File Handling as 08032021 (1).ppt
Raja Ram Dutta
 

Similar to Book (20)

FILES IN C
FILES IN CFILES IN C
FILES IN C
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptx
 
Php files
Php filesPhp files
Php files
 
Files in PHP.pptx g
Files in PHP.pptx                      gFiles in PHP.pptx                      g
Files in PHP.pptx g
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
 
4 text file
4 text file4 text file
4 text file
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdf
 
Python file handlings
Python file handlingsPython file handlings
Python file handlings
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
 
Satz1
Satz1Satz1
Satz1
 
File handling C program
File handling C programFile handling C program
File handling C program
 
Module 5 file cp
Module 5 file cpModule 5 file cp
Module 5 file cp
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
 
Files nts
Files ntsFiles nts
Files nts
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
 
File Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptFile Handling as 08032021 (1).ppt
File Handling as 08032021 (1).ppt
 

Recently uploaded

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

Book

  • 1. This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.
  • 2. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE. file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance. fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to
  • 3. list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the
  • 4. connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a
  • 5. string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles
  • 6. (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of
  • 7. fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file
  • 8. and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only.
  • 9. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen
  • 10. The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this
  • 11. first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to
  • 12. powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose
  • 13. Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof
  • 14. The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file.
  • 15. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use
  • 16. this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing:
  • 17. actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more.
  • 18. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read.
  • 19. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later.
  • 20. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start
  • 21. reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you
  • 22. can add an argument to fgets to limit the maximum line length. For example, use this fopen The fopen function creates the connection to the file. I say "creates the connection" because in addition to opening a file, fopen can open a URL: $fh = fopen("http://127.0.0.1/", "r"); This line of code creates a connection to the page above and allows you to start reading it much like a local file. Note: The "r" used in fopen indicates that the file is open for reading only. Because writing to files is beyond the scope of this article, I'm not going to list all the other options. However, you should change "r" to "rb" if you're reading from binary files for cross-platform compatibility. You'll see an example of this later. feof The feof command detects whether you have already read to the end of the file and returns True or False. The loop in Listing 1 continues until you have reached the end of the file "myfile." Note that feof also returns False if you're reading a URL and the socket has timed out because you no longer have data to read. fclose Skipping ahead to the end of Listing 1, fclose serves the opposite function of fopen: It closes the connection to the file or URL. You are no longer able to read from the file or socket after this function. fgets Learn more. Develop more. Connect more. The new developerWorks Premium membership program provides an all-access pass to powerful development tools and resources, including 500 top technical titles (dozens specifically for open source developers) through Safari Books Online, deep discounts on premier developer events, video replays of recent O'Reilly conferences, and more. Sign up today. Jumping back a few lines in Listing 1, you get to the heart of file processing: actually reading the file. The fgets function is your weapon of choice for this first example. It grabs a single line of data from your file and returns it as a string. From there, you can print or otherwise process your data. The example in Listing 1 nicely prints out an entire file. If you decide to limit the size of the data chunks that you'll deal with, you can add an argument to fgets to limit the maximum line length. For example, use this