简体   繁体   English

为什么当我使用 session_start() 时我的 PHP 文件停止执行?

[英]Why does my PHP file stop executing when I use session_start()?

I am creating a login page for a website using PHP.我正在使用 PHP 为网站创建登录页面。 I added "session_start();"我添加了“session_start();” as seen below to start the session.如下所示开始会话。 Then I put the rest of the websites code below it (other php, html, etc).然后我将其余的网站代码放在它下面(其他 php、html 等)。 Whenever I use session_start, the program stops executing and shows a blank page.每当我使用 session_start 时,程序都会停止执行并显示一个空白页面。 Also, the page displays error 500 on some browsers.此外,该页面在某些浏览器上显示错误 500。 I'm not sure if this is a permission problem.我不确定这是否是权限问题。

How do I properly use session_start()?如何正确使用 session_start()? My code is below.我的代码如下。 When I run it it shows a blank screen.当我运行它时,它显示一个空白屏幕。 When I comment out session_start();当我注释掉 session_start(); it prints "Working...".它打印“工作...”。

<?php 
session_start();
echo "Working...";
?>

Ok I figured it out.好吧,我想通了。 Thanks for the help everyone.谢谢大家的帮助。 After looking at the logs the error read Fatal error: Uncaught Error: Call to undefined function session_start() in /usr/local/www/apache24/data/test.php:2 Stack trace: #0 {main} thrown in /usr/local/www/apache24/data/test.php on line 2查看日志后,错误读取 Fatal error: Uncaught Error: Call to undefined function session_start() in /usr/local/www/apache24/data/test.php:2 Stack trace: #0 {main} throw in /usr /local/www/apache24/data/test.php 第 2 行

All I had to do was install some packages (mod_php72 and php72-session) and restart the server.我所要做的就是安装一些软件包(mod_php72 和 php72-session)并重新启动服务器。

These posts really helped: Call to undefined function session_start() https://forums.freebsd.org/threads/call-to-undefined-function-session_cache_limiter.69010/这些帖子确实有帮助: 调用未定义的函数 session_start() https://forums.freebsd.org/threads/call-to-undefined-function-session_cache_limiter.69010/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么当我 session_start() 时在我的对象上调用 __wakeup()? - Why is __wakeup() called on my object when I session_start()? 为什么我不能在php脚本中使用session_start()? 它说标题已经发送 - Why can't I use session_start() in my php script? It says headers are already sent 我需要在PHP中使用session_start()来使用$ _SESSION吗? - Do I need to use session_start() in PHP to use $_SESSION? 什么时候使用session_start()? - When to use session_start()? 为什么session_start()函数在php构造函数中不起作用? - Why does session_start() function does not work in php constructor? 我可以在每个页面的开头使用session_start()吗,即在我网站的头文件中 - Can i use session_start() at the start of every page i.e in the header file of my website PHP session_start() 函数:为什么每次使用与 PHP 会话相关的任何东西时都需要它 - PHP session_start() function: Why I need it everytime I use anything related to PHP sessions 为什么PHP偶尔挂在session_start()上 - Why does PHP occasionally hang on session_start() 为什么PHP中的session_start抛出警告说文件很大 - why session_start in php is throwing warning saying file large 我在不使用session_start()的情况下在不同的php文件中使用了变量。 我对session_start()缺少什么,什么时候应该使用此函数? - I use variables in different php files without using session_start(). What am I missing about session_start() and when should I use this function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM