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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.