首先,不废话,把解决方案写下来 因此解决方案就是把头输出删除。 具体来说,不用修改任何php.ini,也不用写ob_start() 等来缓存header,直接在session_start前调用一句 ob_end_clean() 即可了。 原创人:surance#gmail.com(请把#替换为@) 后面是解决步骤
首先,不废话,把解决方案写下来
因此解决方案就是把头输出删除。
具体来说,不用修改任何php.ini,也不用写ob_start() 等来缓存header,直接在session_start前调用一句
ob_end_clean()
即可了。
原创人:surance#gmail.com(请把#替换为@)
后面是解决步骤
从phpnow换到xampp后,出现了好多问题(phpnow的主要问题是无法安装zend_extention_ts,道行太浅,怎么也装不上。)。
花了很多时间解决这些问题,也学到很多东西。
这里来记录一下怎样解决session_start的问题。
明明已经没有写任何输出,还是会报headers already sent错误。
网上有人说修改配置文件,有的说修改
output_buffering = On
这样可以把头文件缓存暂不输出;有的说直接把session auto start设置成On,更有人用不着边际的把报错关闭。
其实头2种方法我试过,还是可以的。只是如果网页没有用session,默认开启不是亏了;另外,全部header缓存是否会有问题也难说。
那么,session_start前到底输出了哪些字符呢?可以在session_start前调用
var_dump( headers_list());
来查看一下。
我发现,主要是出现了 X-PoweredBy: 和Content-Type 2个输出。修改PHP.ini的expose_php = off可以关闭x-poweredBy,但是如何关闭输出content-type我就不知道了。
但是,我知道这2个都是没有用的。
因此解决方案就是把头输出删除。
具体来说,不用修改任何php.ini,也不用写ob_start() 等来缓存header,直接在session_start前调用一句
ob_end_clean()
即可了。
可以在php代码里面调用 ob_start()来缓存head的输出

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

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

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use