How to access the current php file in php extension (written in c)?

I am trying to write an extension for php using swig. I need to know the absolute path of the current php file in my incremental code. I used __ FILE __ in my C code, but it returns the current file name c.

+4
source share
2 answers
Finally, I found a solution. to access __ FILE __ in the php extension you can use the following:
char *file_name = zend_get_executed_filename();
+1
source

You can use the realpath () function. Specify the name of the current file.

hint: man 3 realpath or http://www.freebsd.org/cgi/man.cgi?query=realpath&sektion=3

0
source

Source: https://habr.com/ru/post/1536324/


All Articles