How to write a php script that will open a text file?

Tried in the server folder to place the file with this content, file file.txt does not open.

$file = fopen('file.txt','r');
echo("  :   ");

In general, maybe I was deeply mistaken? In my views, a text editor window should appear. If this is not the case, please explain how it works.

Answer 1, Authority 100%

You are trying to open a file located in one folder with an executable script. Check the paths again.

Answer 2

Text Editor window will not appear.
If you have a small file and there is a desire to see its contents, you can use File_Get_Contents ( ) .