我想将http://localhost/content1/index.php?mo=phone&do=setProperty&phoneid=3
中的phone 取出赋给一个变量  和把 setProperty 取出付给一个变量

解决方案 »

  1.   

    这个不需要正则
    直接
    $var1 = $_GET['mo'];
    $var2 = $_GET['do'];
      

  2.   

    支持LS的兄弟,既然LZ要求正则,那么我来写一个简单的正则帮你匹配一下吧<?php
    $a ='http://localhost/content1/index.php?mo=phone&do=setProperty&phoneid=3';
    preg_match_all('/mo=(.+?)&do=(.+?)&/i',$a,$arr);
    $mo = $arr[1][0]; //把phone赋值给变量$mo
    $do = $arr[2][0]; //把setProperty赋值给变量$do
    ?>
      

  3.   

    地址栏传值直接用$_GET获取即可,正则多麻烦