테스트 사이트 - 개발 중인 베타 버전입니다

코드질문좀드리겠습니다. 채택완료

초보입니다1 7년 전 조회 2,551

안녕하세요 코드질문좀드리겠습니다

 

 

</p>

<p>      <?php 

$url = "<a href="http://"" target="_blank" rel="noopener noreferrer">http://"</a> . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; 

 

if($url == G5_URL.'/shop/?type=2'){ 

?> </p>

<p>

위와같은 코드를 이용을 할려고합니다

그런데 주소넣는부분에 

 

/shop/?type=1&maker=1&order=

이렇게 들어가야하는데

& <이게 들어가면 주소로 인식을 안하는지 아예 먹톡이 되더라구요 ㅠㅠ

왜그러는걸까요 해결방법좀있으면 알려주시면 감사하겠습니다 ㅠ

 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
l
7년 전

if($url == G5_URL.'/shop/?type=2'){ 트샷님이 지적하였듯이 이런 코드는 쓰지 않습니다. if ($_GET['type'] == '2') { 이런 식으로 $_GET을 이용하여야 합니다. $_SERVER['REQUEST_URI']에는 생각보다 많은 데이터가 들어옵니다. 그 중에서 쓰고 싶은 것만 추출하여야 하는데 이미 php에서는 $_GET 과 $_POST 배열을 지원하고 있습니다. URL 뒤에 &type=1 이런 값들은 $_GET에 들어오고 폼전송시 대부분 폼 method가 post로 지정되므로 그 때는 $_POST 배열을 사용합니다. 기본지식을 먼저 공부하셔야 할 듯요.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

7년 전

코드와 설명이 잘 매치가 되지 않는 것 같아, 이해가 잘 되지 않습니다.

 

페이지 주소에 따른 처리를 하려는 것이라면, 위 코드보다는 다음과 같은 방식의 코드를 사용해보면 어떨까 싶습니다.

</p>

<p>if ($_GET['type'] === "2" && $_GET['maker'] === "1") {</p>

<p>  //</p>

<p>} else if ($_GET['type'] === "2" && $_GET['maker'] === "2") {</p>

<p>  //</p>

<p>} </p>

<p>else if ($_GET['type'] === "3" && $_GET['maker'] === "1") {</p>

<p>  //</p>

<p>} </p>

<p>// ...</p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

초보입니다1
7년 전
[code]

<?php
$url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

if($url == G5_URL.'/shop/?type=1'){
?>

<!------ Include the above in your HEAD tag ---------->

<div class="container">
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-8 col-xs-9 bhoechie-tab-container">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 bhoechie-tab-menu">
<div class="list-group">
<a href="#" class="list-group-item active text-center">
<p>최신 기능과 디자인을 찾는다면</p>
<h4>프리미엄<br>추천</h4>
</a>
<a href="#" class="list-group-item text-center">
<p>저렴한 가격을 원한다면,</p>
<h4>실속<br>추천</h4>
</a>

</div>
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 bhoechie-tab">
<!-- flight section -->
<div class="bhoechie-tab-content active">
<div class="main_list5">
<ul>
<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>

<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>

<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>

<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>
</ul>


</div>
</div>
<!-- train section -->
<div class="bhoechie-tab-content">
fff
</div>


</div>
</div>
</div>
</div>

<?}?>
<?php
$url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

if($url == G5_URL.'/shop/?type=2'){
?>

<!------ Include the above in your HEAD tag ---------->

<div class="container">
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-8 col-xs-9 bhoechie-tab-container">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 bhoechie-tab-menu">
<div class="list-group">
<a href="#" class="list-group-item active text-center">
<p>최신 기능과 디자인을 찾는다면</p>
<h4>프리미엄<br>추천</h4>
</a>
<a href="#" class="list-group-item text-center">
<p>저렴한 가격을 원한다면,</p>
<h4>실속<br>추천</h4>
</a>

</div>
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 bhoechie-tab">
<!-- flight section -->
<div class="bhoechie-tab-content active">
<div class="main_list5">
<ul>
<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>

<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>

<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>

<li><div class="box"><img src="/img/test.png"></div>
<ul>
<ol id="txt">GIGA Genie</ol>
<ol id="txt1">월 66,800원 ~ </ol>
<ol id="txt2">상세요금제 설명</ol>
</ul>
</li>
</ul>


</div>
</div>
<!-- train section -->
<div class="bhoechie-tab-content">
fff2222
</div>


</div>
</div>
</div>
</div>


<?}?>

[/code]
원본소스입니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인