【PHP】laravel怎么获取网址里面的参数
2 回答
明月笑刀无情
TA贡献1828条经验 获得超4个赞
获取网址参数直接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;
动漫人物
TA贡献1815条经验 获得超10个赞
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php $found = false; $view = array (); $view_list = isset( $_SESSION [ 'view_list' ])? $_SESSION [ 'view_list' ]: array (); $view [ "utm_source" ] = $_GET [ 'utm_source' ]; $view [ "utm_medium" ] = $_GET [ 'utm_medium' ]; $view [ "utm_campaign" ] = $_GET [ 'utm_campaign' ]; $view [ "utm_content" ] = $_GET [ 'utm_content' ]; $time = date ( "Y-m-d H:i:s" ,time()); foreach ( $view_list as $row ){ if ( $row [ "utm_source" ]== $view [ "utm_source" ] && $row [ "utm_medium" ]== $view [ "utm_medium" ] && $row [ "utm_campaign" ]== $view [ "utm_campaign" ] && $row [ "utm_content" ]== $view [ "utm_content" ] &&){ //检测重复 $found = true; break ; } } if (! $found ){ $view_list [ $time ] = $view ; $_SESSION [ 'view_list' ] = $view_list ; $_SESSION [ 'last_view' ] = $view ; } //以上是保存访问历史部分 ?> <?php //下面是在提交时将数据保存到数据库的部分 $view_list = json_encode( $_SESSION [ 'view_list' ]); //将总数组编码后的字符串 $view_last = json_encode( $_SESSION [ 'last_view' ]); //将最后一次访问编码成字符串 //以上两个数据存入数据库即可 ?> <?php //从数据库获取数据 //从数据库取到数据后进行一次json解码就可以拿到原来的数组了如下: //$view_list_str $last_view_str分别是从数据库中读出来的字符串 $view_list_array = json_encode( $view_list_str ); $view_last_array = json_encode( $last_view_str ); ?> |
- 2 回答
- 0 关注
- 1335 浏览
添加回答
举报
0/150
提交
取消