FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Good code or bad code?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Good code or bad code? [message #170181] Sun, 17 October 2010 04:20 Go to previous message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma:
Member
I'm mostly playing with PHP to get a feeling for coding in it.

So as part of all this URI/URL/redirect stuff I spent some time looking
at the contents of $_SERVER and I came up with this code to find the
filename of the file I'm invoked from. Now one condition that I wanted
to cater for was if the filename had multiple "."s in the name, for
instance myfile.inc.php, or something like this.

So I came up with this piece of code.

$uriParts = explode("/",$_SERVER['REQUEST_URI']);
$thisFile = substr(end($uriParts),0,(strlen(end($uriParts))) -
(strlen(end($uriParts))- strrpos(end($uriParts),'.')));

So I was wondering if that is good code or if I could have written it
better, since looking at it it is quite hard to understand.

Thanks
MikeB

I'll go away again for a while after this, I probably have been relying
on all y'alls good graces too much again.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: buffering to allow headers in code?
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 07:39:13 GMT 2024

Total time taken to generate the page: 0.04496 seconds