Re: [PHP] is_prefix() - checking wheather $A is prefix for $B

2007-12-29 Thread Zoltán Németh
2007. 12. 29, szombat keltezéssel 15.36-kor AmirBehzad Eslami ezt írta: > In case you haven't realized it, I have already written two functions > to check > for a prefix !! The question is: Which function is better? > (is_prefix1() or is_prefix2()) ehh, sorry I did not read your mail carefully bef

Re: [PHP] is_prefix() - checking wheather $A is prefix for $B

2007-12-29 Thread Silvio Porcellana
You should benchmark and tell us - anyway, just looking at the code, I'd say 'is_prefix2()' is faster since there's 1 function call instead of 2 AmirBehzad Eslami wrote: In case you haven't realized it, I have already written two functions to check for a prefix !! The question is: Which functi

Re: [PHP] is_prefix() - checking wheather $A is prefix for $B

2007-12-29 Thread AmirBehzad Eslami
In case you haven't realized it, I have already written two functions to check for a prefix !! The question is: Which function is better? (is_prefix1() or is_prefix2()) On 12/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: > > 2007. 12. 29, szombat keltezéssel 13.39-kor AmirBehzad Eslami ezt írta:

Re: [PHP] is_prefix() - checking wheather $A is prefix for $B

2007-12-29 Thread Zoltán Németh
2007. 12. 29, szombat keltezéssel 13.39-kor AmirBehzad Eslami ezt írta: > I want to write a function to check > whether string $A is a prefix for string $B or not. if (strpos($B, $A) === 0) { echo '$B begins with $A'; } else { echo '$B does not begin with $A'; } greets Zoltán Németh > > I w

[PHP] is_prefix() - checking wheather $A is prefix for $B

2007-12-29 Thread AmirBehzad Eslami
I want to write a function to check whether string $A is a prefix for string $B or not. I writing this function in order to prevent directory traversal during a download request. (e.g., download.php?file=..\index.php) I want to make sure that the realpath() of the requested file is within the rea