I'm just starting to learn PHP, and I'm trying out file IO. As far as I can tell, the following script is fine, but it doesn't work right.
<?php
$number = 1;
while (file_exists("post".$number))
{
$title = fopen("post".$number."/title.txt");
$createdBy = fopen("post".$number."/createdBy.txt");
$subtitle = fopen("post".$number."/subtitle.txt");
echo fread($title)."(".fread($subtitle).") was created by ".fread($createdBy);
$number++;
}
?>
When I run this, it returns "() was created by"
Yes, I have verified that all of the included files exist, and yes, all of the files have contents.
<?php
$number = 1;
while (file_exists("post".$number))
{
$title = fopen("post".$number."/title.txt");
$createdBy = fopen("post".$number."/createdBy.txt");
$subtitle = fopen("post".$number."/subtitle.txt");
echo fread($title)."(".fread($subtitle).") was created by ".fread($createdBy);
$number++;
}
?>
When I run this, it returns "() was created by"
Yes, I have verified that all of the included files exist, and yes, all of the files have contents.