php - How to map file path from different folder location easily? -
How to easily map the path of the file?
public_html / api / function php & lt ;? Php function writingfile ($ content) {$ filename = 'logfile / test_randomstring.txt'; If (! $ Handle = fopen ($ filename, 'a')) {resonant "can not open file ($ filename)"; Go out; } Fclose ($ handle); }? & Gt;
The actual path of the text file is in the public_html / r / admin / logfile / test_randomstring.txt
, so if I type the Script on public_html / folder1 / folder2 / addlog.php
, it will not be able to find the path of test_randomstring.txt
addlog.php
How can I easily enable this text file path, even if my php calling script is anywhere.
I have $ filename = 'logfile /testing_randomstring.txt'; Applying it properly on the path to fix, inside the lipatolagfile function, something is like $ $ filename = '/ r / admin / logfile / test_randomstring.txt', but it is not working
Instead of using a relative path, you can specify a full path. Assume that public_html
is in your home directory, try it:
$ filename = '/public_html/r/admin/logfile/testing_randomstring.txt'; Popen (getenv ('HOME'). $ Filename, 'A');
This environment variable uses the $ HOME
to read the contents.
Comments
Post a Comment