问题
在PHP4.2以后的版本中register_global默认为off
若想取得从另一页面提交的变量:
方法一:在PHP.ini中找到register_global,并把它设置为on.
方法二:在接收网页最前面放上这个extract($_POST);extract($_GET);(注意extract($_SESSION)前必须要有Session_Start()).
方法三:一个一个读取变量$a=$_GET["a"];$b=$_POST["b"]等,这种方法虽然麻烦,但比较安全.
PHP代码:
Ob_Start();
Session_Start();
Echo "";<br>Echo "本页得到的_GET变量有:";<br>Print_R($_GET);<br>Echo "本页得到的_POST变量有:";<br>Print_R($_POST);<br>Echo "本页得到的_COOKIE变量有:";<br>Print_R($_COOKIE);<br>Echo "本页得到的_SESSION变量有:";<br>Print_R($_SESSION);<br>Echo "
";
?>
为什么我向另一网页传送变量时,只得到前半部分,以空格开头的则全部丢失
PHP代码:--------------------------------------------------------------------------------
$Var="hello php";//修改为$Var=" hello php";试试得到什么结果
$post= "receive.php?Name=".$Var;
header("location:$post");
?>
--------------------------------------------------------------------------------
receive.php的内容:
PHP代码:--------------------------------------------------------------------------------
Echo "
";<br>Echo <br>转自喜悦村<br>在PHP4.2以后的版本中register_global默认为off若想取得从另一页面提交的变量:方法一:在PHP.ini中找到register_global,并把它设置为on.方法二:在接收网页最前面放上这个extract($_POST);extract($_GET);(注意extract($_SESSION)前必须要有Session_Start()).方法三:一个一个读取变量$a=$_GET["a"];$b=$_POST["b"]等,这种方法虽然麻烦,但比较安全.<br>PHP代码:<?PHPOb_Start ();Session_Start();Echo "<pre class="brush:php;toolbar:false">";Echo "本页得到的_GET变量有:";Print_R($_GET);Echo "本页得到的_POST变量有:";Print_R($_POST);Echo "本页得到的_COOKIE变量有:";Print_R($_COOKIE);Echo "本页得到的_SESSION变量有:";Print_R($_SESSION);Echo "";?>
为什么我向另一网页传送变量时,只得到前半部分,以空格开头的则全部丢失
PHP代码:--------------------------------------------------------------------------------
$Var="hello php";//修改为$Var=" hello php";试试得到什么结果
$post= "receive.php?Name=".$Var;
header("location:$post");
?>
--------------------------------------------------------------------------------
receive.php的内容:
___FCKpd___1
正确的方法是:
PHP代码:--------------------------------------------------------------------------------
$Var="hello php";
$post= "receive.php?Name=".urlencode($Var);
header("location:$post");
?>
--------------------------------------------------------------------------------
在接收页面你不需要使用Urldecode(),变量会自动编码.
规范你的SQL语句在表格,字段前面加上"`",这样就不会因为误用关键字而出现错误,当然我并不推荐你使用关键字.例如$Sql="INSERT INTO `xltxlm` (`author`, `title`, `id`, `content`, `date`) VALUES ('xltxlm', 'use`', 1, 'criterion your sql string ', '2003-07-11 00:00:00')"
我怎么知道系统默认支持什么函数
PHP代码:
--------------------------------------------------------------------------------"; Echo "这里显示系统所支持的所有函数,和自定以函数php\n"; print_r($arr); echo ""; ?> <br>如何比较两个日期相差几天</p>
<p>PHP代码:<br>--------------------------------------------------------------------------------<?PHP $Date_1="2003-7-15";//也可以是:$Date_1="2003-6-25 23:29:14"; $Date_2="1982-10-1"; $Date_List_1=explode("-",$Date_1); $Date_List_2=explode("-",$Date_2); $d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]); $d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]); $Days=round(($d1-$d2)/3600/24); Echo "偶已经奋斗了 $Days 天'"; ?>数据放入数据库和取出来显示在页面需要注意什么入库时$str=addslashes($str);$sql="insert into `tab` (`content`) values('$str')";出库时$str=stripslashes($str);显示时$str=htmlspecialchars(nl2br($str)) ; <br>GET["Name"];<br>Echo "";<br>?></p>
<p>--------------------------------------------------------------------------------</p>
<p>正确的方法是:</p>
<p><br>___FCKpd___2</p>
<p>在接收页面你不需要使用Urldecode(),变量会自动编码.</p>
<p><br>规范你的SQL语句</p>
<p><br>在表格,字段前面加上"`",这样就不会因为误用关键字而出现错误,<br>当然我并不推荐你使用关键字.</p>
<p>例如<br>$Sql="INSERT INTO `xltxlm` (`author`, `title`, `id`, `content`, `date`) VALUES ('xltxlm', 'use`', 1, 'criterion your sql string ', '2003-07-11 00:00:00')"</p>
<p><br>我怎么知道系统默认支持什么函数</p>
<p>___FCKpd___3<br>--------------------------------------------------------------------------------</p>
<p><?php <br/>$arr = get_defined_functions(); <br>Function php() {<br>} <br>echo "</p>
<pre class="brush:php;toolbar:false">"; <br>Echo "这里显示系统所支持的所有函数,和自定以函数php\n"; <br>print_r($arr); <br>echo "";
?>
如何比较两个日期相差几天
___FCKpd___4
--------------------------------------------------------------------------------
$Date_1="2003-7-15";//也可以是:$Date_1="2003-6-25 23:29:14";
$Date_2="1982-10-1";
$Date_List_1=explode("-",$Date_1);
$Date_List_2=explode("-",$Date_2);
$d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]);
$d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]);
$Days=round(($d1-$d2)/3600/24);
Echo "偶已经奋斗了 $Days 天'";
?>
数据放入数据库和取出来显示在页面需要注意什么
入库时
$str=addslashes($str);
$sql="insert into `tab` (`content`) values('$str')";
出库时
$str=stripslashes($str);
显示时
$str=htmlspecialchars(nl2br($str)) ;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools
