首页 > 开发 > PHP > 正文

PHP常见问题

2024-05-04 22:58:10
字体:
来源:转载
供稿:网友



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 ([email protected]($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>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表