I'm trying to write an extension for php using swig. I need to know the absolute path of the current php file in my extension code. I used __ FILE __ in my C code but it returns current c file name.
Asked
Active
Viewed 100 times
2 Answers
1
finally i found the solution. to access __ FILE __ in your php extension, you can use like this:
char *file_name = zend_get_executed_filename();

Ali choobdar
- 121
- 6
0
You can use the realpath() function. Specify the name of your current file.
hint: man 3 realpath or http://www.freebsd.org/cgi/man.cgi?query=realpath&sektion=3

Sébastien P.
- 526
- 3
- 14
-
I dont know the current file name. it might be any file of my project. by the current file name i mean the php file that called the extensions function. – Ali choobdar Apr 13 '14 at 14:30
-
If the OP already knew `pathname` he wouldn't need this function ;-) – Álvaro González Apr 14 '14 at 16:12