Please send questions to
st10@humboldt.edu .
<html>
<!-- files1.php
adapted from example from PHP File section
from W3Schools PHP tutorial,
http://www.w3schools.com/php/php_file.asp
adapted by: Sharon Tuttle
last modified: 12-05-06
-->
<head>
<title> playing with PHP and files - 1 </title>
</head>
<body>
<h2> playing with PHP and files - 1 </h2>
<h3>
<?php
// trying to open a file that EXISTS for reading
if ($fileHandle = fopen("files1.php", "r"))
{
print "Opened files1.php for reading!<br>\n";
print "Now closing it. <br>\n ";
fclose($fileHandle);
}
else
{
print "Could NOT open files1.php!<br>\n";
}
// now trying to open a file that DOESN'T exist for reading
if ($file2Handle = fopen("imaginary.txt", "r"))
{
print "HUH?? Opened imaginary.txt for reading!?<br>\n";
print "Now closing it. <br>\n ";
fclose($file2Handle);
}
else
{
print "HOORAY - could not open imaginary.txt for reading!<br>\n";
}
?>
</h3>
</body>
</head>