Yeah, you can give it a shot I didn't test it. Works alright in my head though
If you aren't learning about file handling or anything like that, then this can be done much easier:
$sFile = __DIR__ . '/quotes.txt';
if (false !== ($aQuotes = file($sFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)))
print $aQuotes[array_rand($aQuotes, 1)];
print 'Cannot retrieve quotes!';
__FILE__ differs in that its the entire path including "this" script. Prior to. . . 5.2.x I think it was, __DIR__ hadn't existed, so we would use dirname(__FILE__) in its place.
It is IMO wise to always include or open files relative to "this" script. Since you can include "this" script in a different one with a different path, PHP takes its cwd as that of the executing script, not the inclusions. Using relatives from __DIR__ will always produce the correct paths.