This interception, right?

Source: Internet
Author: User
See a source code in this write: The intention is to take the slash, but this column, not take the last p, because-1 is the last one AH
echo $php _self;///index.php
if ('/' = = substr ($php _self,-1)) It's not the right thing to say-1 not the last one?


Reply to discussion (solution)

String substr (string $string, int $start [, int $length])
$rest = substr ("abcdef",-1); Return "F"
If start is a negative number, the returned string starts at the end of the string, starting at the start of the first character.

String substr (string $string, int $start [, int $length])
$rest = substr ("abcdef",-1); Return "F"
If start is a negative number, the returned string starts at the end of the string, starting at the start of the first character.


If according to your reasoning, this if ('/' = = substr ($php _self,-1)) is clearly wrong, but the purpose of this sentence is to judge is the truth of the situation, I do not know Ecshop so write what is going on


String substr (string $string, int $start [, int $length])
$rest = substr ("abcdef",-1); Return "F"
If start is a negative number, the returned string starts at the end of the string, starting at the start of the first character.


If according to your reasoning, this if ('/' = = substr ($php _self,-1)) is clearly wrong, but the purpose of this sentence is to judge is the truth of the situation, I do not know Ecshop so write what is going on




He's going to take INDEX.PHP/FASDFASDFASDFAF, which means taking the back part of index.php.

See if there's a index.php behind.

if ('/' = = substr ($php _self,-1))
Just checking to see if the last character of the $php _self is/
You're not mistaken about the use of functions.
But for the purpose of the algorithm, there is no clear understanding

So, when you look at someone else's code, be sure to experience the author's ideas.
Because of the same effect, you might use a completely polarising algorithm

Different ideas and different ways of writing
For example, I hope $php _self behind.
Then will write $php _self = Trim ($php _self, '/');
I don't care if he's got it removed.

And I hope $php _self behind.
Then it will write $php _self = Trim ($php _self, '/'). ‘/’

It is not necessary to first determine the operation

if ('/' = = substr ($php _self,-1)) This is the check whether the last character/

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.