Jump to content

[SOLVED] Get filename of script currently being run..?


DamienRoche

Recommended Posts

Is there a command for obtaining the name of the script being run..obviously a command I would have to run in the script?

 

Can I do this:

 

$thisfile = ///// command I want

 

file_get_contents($thisfile);

 

Basically I want to run my test scripts but also feature the actual code on the same page.

 

Thanks for any help.

This will give funny results on included files. For this you may want

 

file_get_contents( $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'] );

 

I'm 99% sure DOCUMENT_ROOT is derived from the server... but I'm not entirely sure about SCRIPT_NAME... so you may want to sanitize.

Thanks discomatt! __FILE__ works perfectly. I'm running it on a local machine so not sure how that will effect the second method.

 

I'll give the other method a try if I decide to put this online.

 

Thanks again!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.