Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP troubles

Name: Anonymous 2006-01-01 19:01

Are there any predefined variables in php that display the directory that the script is currently being run? The first directory; I mean, not the full path since the doccument root.

If not, is there any way to work around it/remove certain text from a string?

Name: Anonymous 2006-01-01 20:14

1  get full path from $_SERVER['PHP_SELF']
2  split it using EXPLODE into array
3  get whichever item of array you want
4  profit

but maybe i have misunderstood it..

Name: 1 2006-01-01 23:38 (sage)

>>2
Actually I found a solution to this thanks to #php. I ended up using a combination of substr(), strpos(), and strrpos().

Name: 1 2006-01-01 23:38 (sage)

>>2
Actually I found a solution to this thanks to #php. I ended up using a combination of substr(), strpos(), and strrpos().

Name: Anonymous 2006-01-02 3:45

>>4
basename(dirname($_SERVER[PHP_SELF])) is the "official" way to do it, I expect, and might be more readable.

Name: Anonymous 2006-01-02 8:29

>>5
Oh thanks, that's much easier!

Name: 1 2006-01-12 17:04

More problems:
Warning: main(/dynamic.php): failed to open stream: No such file or directory in /var/www/com/general/dyn.php on line 3
Warning: main(): Failed opening '/dynamic.php' for inclusion (include_path='.') in /var/www/com/general/dyn.php on line 3

I keep on getting those two errors, no matter what I try. I've tried to include the file by changing how I request it, I've tried to include the file via HTTP, I've even tried to include the file by changing the include path; I've tried all sorts of things but I can't get it to work. What's the problem?

Name: Anonymous 2006-01-12 17:25

remove the slash

Name: Anonymous 2006-01-12 18:32

>>8
I've tried that. The file is in the main www directory, so I was trying to access it that way.

Name: Anonymous 2006-01-13 2:10 (sage)

if you mean /var/www then you might want to check your current directory right before you get that error. I think you are looking in the wrong path.

Name: Anonymous 2009-01-30 22:04

Name: Anonymous 2009-01-30 22:05

test

Name: Anonymous 2009-01-30 22:06

test test

Name: Anonymous 2011-02-03 6:50

Name: Anonymous 2011-02-04 11:39

Don't change these.
Name: Email:
Entire Thread Thread List