By zidong.c on
I am making a drupal module, which requires open and read a local file under my module directory.
Under windows, I have to write like : fopen('modules/my-module/file-to-open.dat', rb);
Under Linux or Unix : fopen('modules\my-module\file-to-open.dat', rb); instead.
How can I write a sentence which can work well both under windows and linux, without changing codes manually.
Thanks.
Comments
(no title)
It is a php function. You should be able to use normal front slashes everywhere (your example is not right, it is reversed).
In Linux you can use only
fopen("modules/my-module/file-to-open.dat", "rb");and in Windows,
either
fopen("modules/my-module/file-to-open.dat", "rb");(the same)or
fopen("modules\\my-module\\file-to-open.dat", "rb");Backslashes in php are a special character and you need to double them ("escaping")