【PHP】laravel怎么获取网址里面的参数?

【PHP】laravel怎么获取网址里面的参数


MYYA
浏览 1336回答 2
2回答

明月笑刀无情

获取网址参数直接get就行了啊$view = array();$view_list = array();$view[source] = $_GET['utm_source'];$view[medium] = $_GET['utm_medium'];$view[campaign] = $_GET['utm_campaign'];$view[content] = $_GET['utm_content'];$time = time();$view_list[$time] = $view;

动漫人物

123456789101112131415161718192021222324252627282930313233343536373839404142434445<?php$found&nbsp;=&nbsp;false;$view&nbsp;=&nbsp;array();$view_list&nbsp;=&nbsp;isset($_SESSION['view_list'])?$_SESSION['view_list']:array();$view["utm_source"]&nbsp;=&nbsp;$_GET['utm_source'];$view["utm_medium"]&nbsp;=&nbsp;$_GET['utm_medium'];$view["utm_campaign"]&nbsp;=&nbsp;$_GET['utm_campaign'];$view["utm_content"]&nbsp;=&nbsp;$_GET['utm_content'];$time&nbsp;=&nbsp;date("Y-m-d&nbsp;H:i:s",time());foreach($view_list&nbsp;as&nbsp;$row){&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;$row["utm_source"]==$view["utm_source"]&nbsp;&&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row["utm_medium"]==$view["utm_medium"]&nbsp;&&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row["utm_campaign"]==$view["utm_campaign"]&nbsp;&&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row["utm_content"]==$view["utm_content"]&nbsp;&&){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//检测重复&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$found&nbsp;=&nbsp;true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}if(!$found){&nbsp;&nbsp;&nbsp;&nbsp;$view_list[$time]&nbsp;=&nbsp;$view;&nbsp;&nbsp;&nbsp;&nbsp;$_SESSION['view_list']&nbsp;=&nbsp;$view_list;&nbsp;&nbsp;&nbsp;&nbsp;$_SESSION['last_view']&nbsp;=&nbsp;$view;}&nbsp;//以上是保存访问历史部分?>&nbsp;<?php//下面是在提交时将数据保存到数据库的部分$view_list&nbsp;=&nbsp;json_encode($_SESSION['view_list']);//将总数组编码后的字符串$view_last&nbsp;=&nbsp;json_encode($_SESSION['last_view']);//将最后一次访问编码成字符串&nbsp;//以上两个数据存入数据库即可&nbsp;?>&nbsp;<?php//从数据库获取数据//从数据库取到数据后进行一次json解码就可以拿到原来的数组了如下://$view_list_str&nbsp;$last_view_str分别是从数据库中读出来的字符串$view_list_array&nbsp;=&nbsp;json_encode($view_list_str);$view_last_array&nbsp;=&nbsp;json_encode($last_view_str);&nbsp;?>
打开App,查看更多内容
随时随地看视频慕课网APP