SlideShare a Scribd company logo
1 of 22
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 parsingFelix Z. Hoffmann
 
File and directories in python
File and directories in pythonFile and directories in python
File and directories in pythonLifna C.S
 
File handling in C
File handling in CFile handling in C
File handling in CRabin 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
 
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 examplesMuhammed Thanveer M
 
Mashups MAX 360|MAX 2008 Unconference
Mashups MAX 360|MAX 2008 UnconferenceMashups MAX 360|MAX 2008 Unconference
Mashups MAX 360|MAX 2008 UnconferenceElad Elrom
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ pptKumar
 
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 by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by FaixanٖFaiXy :)
 
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 frameworkVladimir Ulogov
 
File handling in c
File handling in cFile handling in c
File handling in cmohit biswal
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++Vineeta Garg
 

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çãoLucas Oliveira
 
Curriculum Vitae of Sean Duncan
Curriculum Vitae of Sean DuncanCurriculum Vitae of Sean Duncan
Curriculum Vitae of Sean DuncanSean Duncan
 
Clases de inglés in company
Clases de inglés in companyClases de inglés in company
Clases de inglés in companyGiovanna Mussini
 
Windmill14jan16 darryl2
Windmill14jan16 darryl2Windmill14jan16 darryl2
Windmill14jan16 darryl2Mueller Darryl
 
Curriculum Vitae Hwanman Park 061316
Curriculum Vitae Hwanman Park 061316Curriculum Vitae Hwanman Park 061316
Curriculum Vitae Hwanman Park 061316Hwanman Park
 
Evaluation Question 5
Evaluation Question 5 Evaluation Question 5
Evaluation Question 5 Katie Bunn
 
Statistical Analysis of Social Attitudes
Statistical Analysis of Social AttitudesStatistical Analysis of Social Attitudes
Statistical Analysis of Social AttitudesRandi Hovey
 
Abc derecho minero
Abc derecho mineroAbc derecho minero
Abc derecho minerolayfu_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 ParentingRandi Hovey
 
Enclave: A Book By Ann Aguirre
Enclave:  A Book By Ann AguirreEnclave:  A Book By Ann Aguirre
Enclave: A Book By Ann AguirreAlta Sprague
 
Windmill14jan16 susan2
Windmill14jan16 susan2Windmill14jan16 susan2
Windmill14jan16 susan2Mueller Darryl
 
Mike Messinger Detailed 1_2017
Mike Messinger Detailed 1_2017Mike Messinger Detailed 1_2017
Mike Messinger Detailed 1_2017Mike Messinger
 

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

File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugevsol7206
 
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.pptxAssadLeo1
 
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3Gheyath M. Othman
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdfRashmiAngane1
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Techglyphs
 
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 fileskeeeerty
 
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 filesKeerty Smile
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operationsmussawir20
 
File Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptFile Handling as 08032021 (1).ppt
File Handling as 08032021 (1).pptRaja Ram Dutta
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxarmaansohail9356
 

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
 
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
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

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