suchen

Heim  >  Fragen und Antworten  >  Hauptteil

php为何已经有输出了但cookie仍然能设置成功呢?

<?phpecho 'some outputs';
var_dump(setcookie('hello', 'world')); // bool(true)


高洛峰高洛峰3062 Tage vor682

Antworte allen(1)Ich werde antworten

  • 三叔

    三叔2016-10-24 11:00:47

    手册上面有提到

    cookie 是 HTTP 标头的一部分,因此 setcookie() 函数必须在其它信息被输出到浏览器前调用。

    但是PHP会默认开启output_buffering


    Antwort
    0
  • StornierenAntwort