4

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.

2 Answers 2

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();
Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

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.
If the OP already knew pathname he wouldn't need this function ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.