Shown in your comments, I'm guessing you need to install the PHP server first.
The simplest way is to goto this page and install XAMPP for your operating system as I'm assuming Windows.
When installed and all the lights are green, or at least the PHP server open up your browser and goto http://localhost
as this should open up a welcome page.
Using XAMPP your web root directory should be located in C:/xampp/htdocs/
and placing your files there with an index.php
and your blah.txt
and it should execute. Because index.php is the defauled opened file refreshing http://localhost
would remove the welcome page and load up your script.
However perhaps this code is simpler to use instead of fopen
:
<?php
if(file_exists($fname = './blah.txt')){
echo file_get_contents($fname);
} else {
echo 'I should have known to set the correct path..';
}
?>