在 PHP 中,多次运行 session_start() 有什么害处吗? [英] In PHP, is there any harm in running session_start() multiple times?

查看:22
本文介绍了在 PHP 中,多次运行 session_start() 有什么害处吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大概有一些小的性能损失,但除此之外?

Presumably there's some tiny performance hit, but beyond that?

推荐答案

来自 the文档:

从 PHP 4.3.3 开始,在会话之前启动后调用 session_start() 将导致 E_NOTICE 级别的错误.此外,第二个会话开始将被忽略.

As of PHP 4.3.3, calling session_start() after the session was previously started will result in an error of level E_NOTICE. Also, the second session start will simply be ignored.

所以不,它不会造成伤害",但会引发错误.而且它发生的事实可能表明您做错了什么,可能需要重新考虑您的代码是如何布局的.

So no, it won't "cause harm", but it'll throw an error. And the fact that it's happening is probably an indicator that you're doing something incorrectly, and might need to re-think how your code is laid out.

这篇关于在 PHP 中,多次运行 session_start() 有什么害处吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆