1 개요[ | ]
- PHP 매직상수 __FILE__
- PHP __FILE__
- PHP 매직상수 중 하나
- 현재 파일의 절대전체경로
Console
Copy
root@zetawiki:~# echo "<?php var_dump(__FILE__);" > /tmp/test.php
root@zetawiki:~# php /tmp/test.php
string(13) "/tmp/test.php"
2 심볼릭 링크인 경우[ | ]
Console
Copy
root@wsl:/tmp/dir1# ll
total 96
drwxr-xr-x 3 root root 4096 Oct 11 00:51 .
drwxrwxrwt 974 root root 81920 Oct 11 00:51 ..
drwxr-xr-x 2 root root 4096 Oct 11 00:51 dir2
-rw-r--r-- 1 root root 28 Oct 11 00:50 file1.php
lrwxrwxrwx 1 root root 9 Oct 11 00:51 file2.php -> file1.php
Console
Copy
root@wsl:/tmp/dir1# cat file1.php
<?php
echo __FILE__."\n";
Console
Copy
root@wsl:/tmp/dir1# php file1.php
/tmp/dir1/file1.php
- → file1.php 파일을 실행하면 file1.php의 절대경로를 보여준다.
Console
Copy
root@wsl:/tmp/dir1# php file2.php
/tmp/dir1/file1.php
- → 심볼릭 링크인 file2.php를 실행해도 원래 파일 file1.php의 절대경로를 보여준다.
3 같이 보기[ | ]
4 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.