[英]Issues accessing GET variables in CodeIgniter
Is there a way to retrieve the parameters in the URL inside your HTML page like you would normally use $_GET
but in CodeIgniter? 有没有办法像通常在CodeIgniter中使用
$_GET
一样在HTML页面内的URL中检索参数?
For instance, if you were in the view and had the URL: http://www.mysite.com/controller/function/var1/var2 例如,如果您在视图中并且具有URL: http : //www.mysite.com/controller/function/var1/var2
Then how would you be able to access what var1
and var2
were? 那么您将如何访问
var1
和var2
?
you can also access it as if its a function. 您也可以像访问其功能一样访问它。
for example: 例如:
public function somePage($var, $var2) {
//get var
echo "you can access ".$var." like this<br />";
echo "or like this, ".$var2;
}
if you go to for example somesite.com/mypage/access/1/3 如果您转到例如somesite.com/mypage/access/1/3
you'd get the following: 您将获得以下内容:
you can access 1 like this
or like this, 3
what Yan wrote is true as well, though know that you can do it like this too to save on typing. Yan所写的内容也是正确的,尽管您知道您也可以这样做,以节省输入内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.