Jump to content

[SOLVED] Using the filename in an include!


Riseykins

Recommended Posts

your example shows you having a directory named bob

 

are you looking to have a variable that would refrence bob and know what directory to goto based of the variable? or have it do the same in concept but with a file name instead? What are you trying to do?

 

Gotta give us a little bit more then your first post to work with if we are to be able to help you

Link to comment
Share on other sites

I just need it to take the filename and get it to come out within the file.

 

I have many files that are in a directory. Each file corresponds with images located in directories that have the same name as the file.

 

So, when you visit the page bob.php, the images in the directory bob are displayed. If the filename is tim.php then the images in the tim directory show.

 

I can't really explain it any better. :s

 

I need to echo the filename, really. But can I do this inside:

 

<? php include("/home/user/public_html/ECHOFILENAME/file.php"); ?>

Link to comment
Share on other sites

Solon, that's not what I'm trying to do. :(

 

I'll try and explain again. xD

 

Okay, so say I have the following file:

 

<? php include("/home/user/public_html/FILENAMEHERE/file.php"); ?>

 

If I change the name of the file containing that code to bob, the file automatically does this:

 

<? php include("/home/user/public_html/bob/file.php"); ?>

 

When I change it to jim, it becomes:

 

<? php include("/home/user/public_html/jim/file.php"); ?>

 

I have loads of files that are all identical to each other except for that one thing so it's annoying to have to open each file I make and change it. xD

Link to comment
Share on other sites

to change the contents of a txt file automatically when the filename changes would not be php, it would probably be something in c/c++ running as a process in the background of the OS. it would recognize rename actions, save the address of the file, wait for the rename to complete and then open the file, locate a line starting with include('/home/user/public_html/ and change the next word to the new file name.

 

good luck learning a new language.  :P;D

Link to comment
Share on other sites

to change the contents of a txt file automatically when the filename changes would not be php, it would probably be something in c/c++ running as a process in the background of the OS. it would recognize rename actions, save the address of the file, wait for the rename to complete and then open the file, locate a line starting with include('/home/user/public_html/ and change the next word to the new file name.

 

good luck learning a new language.  :P;D

 

...What?

<?php
$base = basename(__FILE__, '.php');
include("$base/file.php");

 

......

Yeah.

Link to comment
Share on other sites

i was under the impression that he want's the to detect rename (F2) in the OS and change 1 word inside the file automatically... it may be that i'm just really tired. i'm going to bed. good night.

 

LOL, good night.  And just so you know, my script automatically takes the current filename and parses out everything except the actual name (it even cuts off the extension) so he can directly include() it. ;)

Link to comment
Share on other sites

  • 2 weeks later...
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.