포워드에 따라 다른 페이지로 자동연결되는 index.php

포워드에 따라 다른 페이지로 자동연결되는 index.php

QA

포워드에 따라 다른 페이지로 자동연결되는 index.php

본문

포워드에 따라 다른 페이지로 자동연결되는 index.php를 만드려는데요..

페이지가 계속 로딩중만되는데 어디가 문제인걸까요?


<!DOCTYPE html>
 
<head>
     <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="http://localhost/style.css">
</head>
<?php
//http://test.kr/index.php?forward=A
if ($forward != "A")
//echo("<script>location.replace('./A.html');</script>");
echo("<meta http-equiv='refresh' content='0'; url='./A.html'>");
elseif ($forward != "B")
echo("<script>location.replace('./B.html');</script>");
elseif ($forward != "C")
echo("<script>location.replace('./C.html');</script>");
elseif ($forward != "D")
echo("<script>location.replace('./D/D.html');</script>");
end;
?>

이 질문에 댓글 쓰기 :

답변 5

첫번째 if 문이 항상 참(TRUE) 이 되기 때문에


echo("<meta http-equiv='refresh' content='0'; url='./A.html'>");

계속 반복 되는 것으로 보입니다.

!= 은 아닌경우 모두를 포함하기 때문에 범위가 지정된 "A"를 제외한 모두가 됩니다.

== 으로 변경하시는게 좋을거 같습니다.

 

우선 if 문이 이상하네요..

forward=A 라면..

4개의 if 문에 모두 해당되고, 젤 위에 if ($forward != "A") 문을 먼저 실행합니다.

즉, ./A.html 파일로 이동하겠네요.

./A.html 파일에 위에 구문이 동일하게 들어가있다면 무한 반복을 하구요.

그렇지 않다면, 이상없이 이동할 겁니다.

구문을 한번 점검해보세요..

<meta http-equiv='refresh' content='0;url=./A.html'>

일단 if 문법도 이상하네요

":" 이 없는데 endif 아닌 end 를 쓰는것도 이상하고 


$forwardUrl = "";

if ($forward != "A") {
   $forwardUrl = "A.html";
} elseif ($forward != "B") {
   $forwardUrl = "B.html";
} ...
echo("console.log('".forwardUrl."');</script>");


이렇게 해서 먼저 console 로그 부터 확인한뒤에 고치든지 해보세요 

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT