왕 기초 테스트

왕 기초 테스트입니다.
전 세계에 배포하는 솔루션이라고 했를때
어떤 값이 나올까요?
 
$_SESSION["USERID"] = "bengi";
.................
.................
.................
$USERID = "sir";
.................
.................
echo $_SESSION["USERID"];
 
 
 
|

댓글 4개

너무 왕 기초라
설문 참여 않하시나 봅니다.....ㅎㅎㅎ
아무생각없이 일단 sir을 누르고 봤습니다 ㅋㅋ
혹시 register_globals 와 관련이 있을까 해서 테스트 해봤는데 전혀 상관이 없네요 ㅋㅋ
[ 해답 ]

위치 : http://php.net/manual/en/reserved.variables.session.php

Please note that if you have register_globals to On, global variables associated to $_SESSION variables are references, so this may lead to some weird situations.

<?php

session_start();

$_SESSION['test'] = 42;
$test = 43;
echo $_SESSION['test'];

?>

Load the page, OK it displays 42, reload the page... it displays 43.

The solution is to do this after each time you do a session_start() :

<?php

if (ini_get('register_globals'))
{
foreach ($_SESSION as $key=>$value)
{
if (isset($GLOBALS[$key]))
unset($GLOBALS[$key]);
}
}

?>


---------------------------------------------------

미국에서 구매한 솔루션이라고 하기에
믿었건만....

정답은 JMoon 님....^-^
댓글을 작성하시려면 로그인이 필요합니다.

자유게시판

+
제목 글쓴이 날짜 조회
12년 전 조회 2,253
12년 전 조회 1,118
12년 전 조회 1,247
12년 전 조회 1,350
12년 전 조회 1,234
12년 전 조회 9,066
12년 전 조회 1,587
12년 전 조회 1,182
12년 전 조회 1,215
12년 전 조회 1,574
12년 전 조회 2,024
12년 전 조회 1,850
12년 전 조회 1,114
12년 전 조회 2,828
12년 전 조회 1,178
12년 전 조회 1,133
12년 전 조회 1,288
12년 전 조회 8,650
12년 전 조회 2,324
12년 전 조회 1,427
12년 전 조회 1,298
12년 전 조회 3,108
12년 전 조회 1,295
12년 전 조회 1,592
12년 전 조회 4,502
12년 전 조회 1,249
12년 전 조회 1,198
12년 전 조회 1,149
12년 전 조회 1,451
12년 전 조회 1,915