English 中文(简体)
《刑法》中的“URL”碎片?
原标题:Optional URL fragment in Codeigniter?

这可能是一个简单的语气问题,也可能是一个在密码上的最佳做法问题。

首先,我要说的是,I m不是PHP或Proigniter人,他们试图迅速帮助项目。

我发现 CI的文件相当好。 我无法找到一个答案是,如何成为《URL任择议定书》的一部分。 举例来说,CI文件的使用是:

example.com/index.php/products/shoes/sandals/123

之后,用于教化国际独立研究所的职能:

function shoes($sandals, $id)

例如,我谨对《欧洲刑法》作如下修改:

example.com/index.php/products/shoes/all

因此,如果不通过身份证,它就受到忽视。 能否做到这一点? 是否应该这样做?

第二个问题与我的问题无关,但与上述例子有关,为什么将可变的美元种用作例子,其价值是沙子? 变量是否像鞋类一样?

最佳回答

可以通过确定以下违约价值来方便地做到这一点:

function shoes($type =  all , $id = null)
{
   //assume the default type of shows: all
   //assume no ID (and do whatever behaviour - e.g. top 5 in that type)
}

请注意,我认为你必须具体说明左边的右边之处,以具体说明某些权利。 您可以有一个任择性的第一部分,一个必要的最右部分。

问题回答

你们可以采取两种方式......

function shoes($type = "all", $id = false)
{
    if ($type == "all")
    {

       // ... here you can show all

    } 
    else if (is_int($id))
    {

       // ...

    }
}

第二,......

function shoes()
{
    $type = $this->uri->segment(3,  all );
    $id = $this->uri->segment(4, false);

    // ... everything else can be same like first example

}




相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签