2

랜덤으로 불러오는 소스 질문좀드립니다

★1
<?=rims_latest('index_F1')?>

★2
<?=rims_latest('index_F2')?>

★3
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 728*90 -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1111111111111111"
data-ad-slot="1111111111"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>



첫번째와 두번째꺼는 최신글 불러오는소스이고

3번째는 구글애드센스 소스입니다

셋중에 하나씩 랜덤으로 출력되게 하고싶은데요

코드좀 알려주시면 감사하겠습니다,.
|

댓글 5개

$randpix = rand(1,3);

switch ($randpix)
{
case 1:
echo rims_latest('index_F1');
break;

case 2:
echo rims_latest('index_F2');
break;

case 3:
echo "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<!-- 728*90 -->
<ins class=\"adsbygoogle\"
style=\"display:inline-block;width:728px;height:90px\"
data-ad-client=\"ca-pub-1111111111111111\"
data-ad-slot=\"1111111111\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
break;
}

이런 식으로 하시면 됩니다.
<?
$randpix = rand(1,3);

switch ($randpix)
{
case 1:
echo rims_latest('index_F1');
break;

case 2:
echo rims_latest('index_F2');
break;

case 3:
echo "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<!-- 728*90 -->
<ins class=\"adsbygoogle\"
style=\"display:inline-block;width:728px;height:90px\"
data-ad-client=\"ca-pub-1111111111111111\"
data-ad-slot=\"1111111111\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
break;
}


?>

이렇게 입력했는데

Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '$' in /home/hosting_users/tmdrhks0112/www/skin/board/basic/view.skin.php on line 257



라고 오류가 나오네요;
해당 파일의 257 라인의 소스가 뭔가요?
파서 에러인데 257 라인 좀 적어 주실래요?
<!-- 728*90 -->
<ins class=\"adsbygoogle\"
style=\"display:inline-block;width:728px;height:90px\"
data-ad-client=\"ca-pub-1111111111111111\"
data-ad-slot=\"1111111111\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>";
break;

작성해주신 소스에서 오류가납니다

echo 사이에 스크립트가 들어가서 생기는오류같습니다
일단 php 로 ★1 ★2 ★3 을 다 불러오신 후,

jQuery 로 random 하게 보여주는 편법? 꼼수? 는 어떠신가요?

this.randomcase = function(){
var length = $("#case li").length;
var ran = Math.floor(Math.random()*length) + 1;
$("#case li:nth-child(" + ran + ")").show();
};

$(document).ready(function(){
randomcase();
});

저도 동일한 상황에서 제가 사용하는 php random 스크립트가 parse error 를 뿜어내서 해결봤던 꼼수 입니다. (불려와지는 내용에 자스가 포함되니까 에러를 뿜더라구요.)

이런 해결책이 맘에 드시지 않을지도... 단지 저는 현실적인 해결책이 필요했어서, 이렇게 했었습니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
12년 전 조회 1,818
12년 전 조회 1,917
12년 전 조회 4,488
12년 전 조회 1,584
12년 전 조회 2,036
12년 전 조회 1,126
12년 전 조회 841
12년 전 조회 1,071
12년 전 조회 1,961
12년 전 조회 1,590
12년 전 조회 1,130
12년 전 조회 1,876
12년 전 조회 1,018
12년 전 조회 1,021
12년 전 조회 1,081
12년 전 조회 1,702
12년 전 조회 1,679
12년 전 조회 884
12년 전 조회 1,687
12년 전 조회 1,652