Thinkphp Object-oriented issues

Source: Internet
Author: User
TP Framework Pagination Class I saw it from the beginning. A private property is defined $url = ';
I think there are two places here that use this private property.
This private method runs to this private method on the top of this show method $url This property is empty, does it not error?

private function url($page){        return str_replace(urlencode('[PAGE]'), $page, $this->url);    }public function show() {        if(0 == $this->totalRows) return '';        $this->parameter[$this->p] = '[PAGE]';        $this->url = U(ACTION_NAME, $this->parameter);……

Reply content:

TP Framework Pagination Class I saw it from the beginning. A private property is defined $url = ';
I think there are two places here that use this private property.
This private method runs to this private method on the top of this show method $url This property is empty, does it not error?

private function url($page){        return str_replace(urlencode('[PAGE]'), $page, $this->url);    }public function show() {        if(0 == $this->totalRows) return '';        $this->parameter[$this->p] = '[PAGE]';        $this->url = U(ACTION_NAME, $this->parameter);……

Are you sure you understand programming?
All functions exist to define and invoke two procedures, and you see two defined processes.
The use of variables in the definition process does not really use variables, and variables are used in the process of invocation.
So the order of the definition does not affect the value of the variable, but also the above and below points.

The description of the Str_replace function has a sentence: the function is binary safe.
Binary security, as I understand it, can handle any byte input correctly, even if it contains 0 value bytes. The concept of binary security can also be searched by the owner.

Is your URL a private property or a private method?

$this->url This private property is defined in your Show method and will not be empty.

What's the answer? Dizzy, is it a programmer?

First he is a class, you call is not a static function, so the URL is created when the class instance is initialized, he is ", empty string, not undefined, is defined but is empty. So there will be no error.

  • 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.