需要了解CodeIgniter中的$config["uri_segment"]相关代码

Need understanding $config["uri_segment"] related code in CodeIgniter

嘿 CodeIgniter 开发人员我是 codeIgniter 的新手,请查看我与分页相关的代码。分页工作正常。我只需要你的帮助来理解几行代码,请参阅代码中的注释行,我只需要你的帮助来理解它。

public function example1() {
        $config = array();
        $config["base_url"] = base_url() . "welcome/example1";
        $config["total_rows"] = $this->services->record_count();
        $config["per_page"] = 10;
        $config["uri_segment"] = 3; // Need help on this line
        $config["next_link"] = '>';
        $config["prev_link"] = '<';

        $this->pagination->initialize($config);
        // Need help on this if condition blocks
        if ($this->uri->segment(3)) {
            $page = ($this->uri->segment(3));
        } else {
            $page = 1;
        }
        $data["results"] = $this->services->fetchServicesByPagination($config["per_page"], $page);
        $data["links"] = $this->pagination->create_links();

        $this->load->view("example1", $data);
    }

同意 Javier Larroulet

来自 Codeigniter 文档 $config['uri_segment'] 定义了 URI segment 将包含页码的内容。它默认为 3,但如果需要,您可以使用其他段。 if clause 上的 $this->uri->segment(3) 条件正在检查是否设置了 URI Segment 数字 3(方法名称之后的第一个)。如果已设置,则使用其值作为页码,否则默认为第 1 页。Reference