Current location: Hot Scripts Forums » Programming Languages » PHP » get current file name as variable


get current file name as variable

Reply
  #11 (permalink)  
Old 07-24-03, 11:48 AM
ChristGuy ChristGuy is offline
Operations Support Develo
 
Join Date: Jun 2003
Location: Rivonia, South Africa
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Thanx... Man Down....

That would explain the null result... *slaps side of head* Doh...
__________________
Till We Meet Again...
Clifford W. Hansen
Aspivia (Pty) Ltd

"We Have Seen Strange Things Today!" Luke 5:26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #12 (permalink)  
Old 07-24-03, 12:40 PM
paulj000 paulj000 is offline
Bull in a china shop
 
Join Date: Jul 2003
Location: California, USA
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

This updated code...

PHP Code:

<?

$currentFile 
$_SERVER["SCRIPT_NAME"];
  
$parts Explode('/'$currentFile);

  print 
$parts[count($parts) - 1];
?>
On server 1 (Hostway) ouptut: php

On server 2 (OnSmart) output: file.php

Yay!! it works on the second server and almost on the first!

Hostway is a good company but maybe they are doing something weird with their config. Earlier in this thread the output was:
cgi-bin/php

Any thoughts on how to get it to work on the Hostway servers?

Thanks a bunch, this code is going to help me out a whole bunch!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #13 (permalink)  
Old 07-24-03, 01:26 PM
Man Down Man Down is offline
HS Staff
 
Join Date: Jun 2003
Location: Maryland
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
ON hostway server try this code:

PHP Code:

<?

$currentFile 
$_SERVER["PHP_SELF"];
  
$parts Explode('/'$currentFile);

  print 
$parts[count($parts) - 1];
?>
__________________
Man Down
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #14 (permalink)  
Old 07-24-03, 04:07 PM
paulj000 paulj000 is offline
Bull in a china shop
 
Join Date: Jul 2003
Location: California, USA
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Case Closed.

This one using "PHP_SELF" works on both servers. Even better.

Thanks a bunch fellas for all of your help!

- Paul
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #15 (permalink)  
Old 07-24-03, 06:40 PM
Cagez's Avatar
Cagez Cagez is offline
Eeew, dirty!
 
Join Date: Jun 2003
Location: Toronto, Ontario
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
What about $_SERVER['PHP_SELF'] ?

Quote:
The filename of the currently executing script, relative to the document root.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #16 (permalink)  
Old 07-24-03, 07:28 PM
Man Down Man Down is offline
HS Staff
 
Join Date: Jun 2003
Location: Maryland
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
If the file that executes $_SERVER[PHP_SELF] is in a sub directory it would make it folder/filename.ext
__________________
Man Down
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #17 (permalink)  
Old 07-24-03, 07:37 PM
Cagez's Avatar
Cagez Cagez is offline
Eeew, dirty!
 
Join Date: Jun 2003
Location: Toronto, Ontario
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Oh gees, i didn't even see this whole 2nd page
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Web Host, New Problem! justchat PHP 2 09-29-03 03:39 PM
Writes to a text file gamextremer2003 JavaScript 4 09-11-03 10:43 AM
Upload file type and size limiter! Arctic ASP 1 08-02-03 08:06 PM
how to get info from TXT file between %%customTags%% as vars?? paulj000 PHP 2 07-26-03 06:00 AM
ASP Renaming a file (with some filename parsing) camt ASP 2 06-30-03 10:53 PM


All times are GMT -5. The time now is 04:27 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.