Re: [PHP] SCRIPT_NAME

2005-10-21 Thread Minuk Choi

... what, the off by one error?

Hey, I was just providing suggestion off the top of my head. :-P

-Minuk

Robert Cummings wrote:


On Thu, 2005-10-20 at 23:27, Minuk Choi wrote:
 


Off the top of my head...

$filename = $_SERVER['PHP_SELF'];

$strippedFilename = substr($filename, strrpos($filename, '/'));
   



Won't work, I'll leave the reason as an exercise :B

Cheers,
Rob.
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-21 Thread Robert Cummings
On Fri, 2005-10-21 at 19:58, Minuk Choi wrote:
 ... what, the off by one error?
 
 Hey, I was just providing suggestion off the top of my head. :-P

Oh I know, I was just pointing out that it won't work :) Doesn't work
because it only strips off the first path segment (assuming no off by
one error also ;). For instance:

/a/b/c/d/foo.php

becomes:

a/b/c/d/foo.php

but the OP wanted:

foo.php

:)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-21 Thread Jasper Bryant-Greene
On Fri, 2005-10-21 at 21:01 -0400, Robert Cummings wrote:
 Oh I know, I was just pointing out that it won't work :) Doesn't work
 because it only strips off the first path segment (assuming no off by
 one error also ;). For instance:
 
 /a/b/c/d/foo.php
 
 becomes:
 
 a/b/c/d/foo.php
 
 but the OP wanted:
 
 foo.php

It will actually work... Did you not notice that he was using
strrpos() ? Note the extra 'r' in there :) http://php.net/strrpos

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-21 Thread Robert Cummings
On Sat, 2005-10-22 at 10:02, Jasper Bryant-Greene wrote:
 On Fri, 2005-10-21 at 21:01 -0400, Robert Cummings wrote:
  Oh I know, I was just pointing out that it won't work :) Doesn't work
  because it only strips off the first path segment (assuming no off by
  one error also ;). For instance:
  
  /a/b/c/d/foo.php
  
  becomes:
  
  a/b/c/d/foo.php
  
  but the OP wanted:
  
  foo.php
 
 It will actually work... Did you not notice that he was using
 strrpos() ? Note the extra 'r' in there :) http://php.net/strrpos

Yep I stand corrected :) Didn't notice the extra 'r' at all *heheh*.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] SCRIPT_NAME

2005-10-20 Thread John Taylor-Johnston
SCRIPT_NAME and PHP_SELF always include leading url information and 
slashes. Is there a function I can use to skin either down to the 
filename? No slashes or leading url.

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-20 Thread Jasper Bryant-Greene
On Thu, 2005-10-20 at 22:22 -0400, John Taylor-Johnston wrote:
 SCRIPT_NAME and PHP_SELF always include leading url information and 
 slashes. Is there a function I can use to skin either down to the 
 filename? No slashes or leading url.

http://php.net/basename for filesystem paths

http://php.net/parse_url for URLs

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-20 Thread Robert Cummings
On Thu, 2005-10-20 at 22:22, John Taylor-Johnston wrote:
 SCRIPT_NAME and PHP_SELF always include leading url information and 
 slashes. Is there a function I can use to skin either down to the 
 filename? No slashes or leading url.

echo ereg_replace( '^.*/', '', $_SERVER['SCRIPT_NAME'] )

ereg is greedy, it'll match as much as it can.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-20 Thread Minuk Choi

Off the top of my head...

$filename = $_SERVER['PHP_SELF'];

$strippedFilename = substr($filename, strrpos($filename, '/'));

references :
http://us3.php.net/substr

http://us3.php.net/manual/en/function.strrpos.php

-Minuk

John Taylor-Johnston wrote:

SCRIPT_NAME and PHP_SELF always include leading url information and 
slashes. Is there a function I can use to skin either down to the 
filename? No slashes or leading url.

John



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SCRIPT_NAME

2005-10-20 Thread Robert Cummings
On Thu, 2005-10-20 at 23:27, Minuk Choi wrote:
 Off the top of my head...
 
 $filename = $_SERVER['PHP_SELF'];
 
 $strippedFilename = substr($filename, strrpos($filename, '/'));

Won't work, I'll leave the reason as an exercise :B

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php