网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   PHP (https://www.0058.net/forumdisplay.php?f=75)
-   -   $_get用法一例 (https://www.0058.net/showthread.php?t=4910)

Naples 2014-12-26 07:43 PM

$_get用法一例
 
Code:

<?php
echo $_GET["name"]."<br>";
echo $_GET["sex"]."<br>";
echo $_GET["email"]."<br>";
print_r($_GET);
?>

<a href="demo.php?name=eye&sex=man&email=info@google.com">test</a>

运行结果为:
Code:

eye
man
info@google.com
Array ( [name] => eye [sex] => man [email] => info@google.com )

注意:这里加下$_GET, 在php.ini设置中的register global=off状态下也能正常运行。如不加$_GET就不行了。
Code:

<?php
echo $name."<br>";
echo $sex."<br>";
echo $email."<br>";
?>

<a href="demo.php?name=eye&sex=man&email=info@google.com">test</a>

上边的代码,如在php.ini设置中的register global=off下执行,就会出错。

在对发出的数据不要安全,且数据不大,可用get方式:
Code:

<?php
print_r($_POST);
?>

<form actiion="demo.php" method="get">
        username: <input type="text" name="uname"><br>
        password: <input type="password" name="pass"><br>
        <input type="submit" value="login">
</form>



All times are GMT +8. The time now is 03:04 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.