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
Re: Good code or bad code? [message #170187 is a reply to message #170181] Sun, 17 October 2010 12:47 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 10/17/2010 12:20 AM, MikeB wrote:
> 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.

In addition to what Hammish said, this information is sent by the
browser and cannot be trusted. Some browsers may not send it, and if it
is sent, it may be falsified (i.e. by a hacker).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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:36:24 GMT 2024

Total time taken to generate the page: 0.27624 seconds