jQuery .load和PHP会话开始 [英] jQuery .load and PHP session start
问题描述
我目前正在使用PHP和jQuery开发游戏,有时需要使用jQuery的.load()将PHP页面加载到div中.该页面将根据他们的登录信息,帐户ID等加载一些玩家信息,这些信息存储在 $ _ SESSION ["arrayname"]
内的数组中.
I am currently working on a game in PHP and jQuery and at some point I will need to use the .load() from jQuery to load a PHP page into a div. That page will load some player information based on their login information, account id, etcetera, stored into an array inside $_SESSION["arrayname"]
.
除了在使用jQuery load()的网站上,它在所有网站上均能完美运行.在easyphp上,我没有任何错误,但是在我的Web主机服务器上,我得到了这个信息:
It works perfectly on all sites, except those where jQuery load() is use. On easyphp, I got no errors, but on my web host server im getting this:
警告:session_start()[function.session-start]:无法发送会话缓存限制器-在线上fr/game/map.php中已发送的标头(输出从/fr/game/map.php:1开始)6
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /fr/game/map.php:1) in fr/game/map.php on line 6
这是我的代码:
<?php
require_once("../../connectionRO.inc.php");
//used to check if we see the array in session, and i dont when i load it with jquery
if(!ISSET($_SESSION["comptejeu"]))
{
require_once('../../classInfoCompte.php');
session_start();
require_once('../../lg.php');
require_once("./glg.php");
}
$ic = new infoCompte;
$ic = $_SESSION["comptejeu"];
?>
我了解到这一点,在加载页面之前,已经有很多东西输出到页面上了.谁能为我指出一种更好的方法,从该数组中检索我需要的信息以从类中构建对象?
I understand that at this point a lot of stuff is already output to the page before that is loaded. Could anyone point me to a better way to retrieve the information that I need from that array to build my object from my class?
谢谢.
推荐答案
由于在/fr/game/map.php:1 开始输出时出现此错误,因此出现此错误(注意:行> 1 ),我会在
/fr/game/map.php
中打开<?php
标记之前给您留有空格或BOM的钱.
Since you are getting this error as output started at /fr/game/map.php:1
(note: line 1) I will place money on you having whitespace or a BOM before the opening <?php
tag in /fr/game/map.php
.
确保开头的<
是文件中的第一个字符第一个.如果文件为UTF-8,请确保其为UTF-8 没有 BOM,或将其转换为ASCII.
Make sure the opening <
is the first character in the file. If you file is UTF-8, make sure it is UTF-8 without BOM, or convert it to ASCII.
错误:
<?php
右:
<?php
这篇关于jQuery .load和PHP会话开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!