PHP常见问题
时间:2007-02-17 来源:PHP爱好者
1.配置PHP.ini,修改session.save_path
如:session.save_path = d:/developer/PHP/temp 或 /tmp
2.程序
1.PHP
<?
session_start();
$var1 = "test";
session_register("var1");
?>
2.PHP
<?
session_start();
echo $var1;
?>
首先运行1.PHP,然后运行2.PHP,页面应该出现test
错误提示:Cannot send session cookie - headers already sent by ...
出现该错误是页面中session_start();语句前存在输出语句
如下例:
<HTML>
<?
session_start();
$var1 = "test";
session_register("var1");
?>
<body>
</body>
</HTML>
将<HTML>放到后面即可
修改PHP.ini
upload_tmp_dir=d:/temp 或 /tmp
upload.PHP
====================================
<HTML>
<head>
<title>PHP Upload</title>
<meta http-equiv="Content-Type" content="text/HTML; charset=??????">
</head>
<body>
<?
if ($upload){
$real_path = $userfile_name;
if (file_exists($real_path)){
unlink($real_path);
}
if (!@copy($userfile,$real_path))
$upload_flag = false;
else
$upload_flag = true;
}
?>
<form name="frmUpload" action="upload.PHP" enctype="multipart/form-data" method="post">
<table border=0 cellspacing=0 cellpadding=4>
<tr><td>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<td>
<input type="file" name="userfile" size="40">
<input type="submit" name="upload" value=" 上载 ">
</td></tr>
</table>
</form>
</body>
</HTML>
php爱 好者站 http://www.phpfans.net 文章|教程|下载|源码|论坛.
如:session.save_path = d:/developer/PHP/temp 或 /tmp
2.程序
1.PHP
<?
session_start();
$var1 = "test";
session_register("var1");
?>
2.PHP
<?
session_start();
echo $var1;
?>
首先运行1.PHP,然后运行2.PHP,页面应该出现test
错误提示:Cannot send session cookie - headers already sent by ...
出现该错误是页面中session_start();语句前存在输出语句
如下例:
<HTML>
<?
session_start();
$var1 = "test";
session_register("var1");
?>
<body>
</body>
</HTML>
将<HTML>放到后面即可
修改PHP.ini
upload_tmp_dir=d:/temp 或 /tmp
upload.PHP
====================================
<HTML>
<head>
<title>PHP Upload</title>
<meta http-equiv="Content-Type" content="text/HTML; charset=??????">
</head>
<body>
<?
if ($upload){
$real_path = $userfile_name;
if (file_exists($real_path)){
unlink($real_path);
}
if (!@copy($userfile,$real_path))
$upload_flag = false;
else
$upload_flag = true;
}
?>
<form name="frmUpload" action="upload.PHP" enctype="multipart/form-data" method="post">
<table border=0 cellspacing=0 cellpadding=4>
<tr><td>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<td>
<input type="file" name="userfile" size="40">
<input type="submit" name="upload" value=" 上载 ">
</td></tr>
</table>
</form>
</body>
</HTML>
php爱 好者站 http://www.phpfans.net 文章|教程|下载|源码|论坛.
相关阅读 更多 +