php 처음 다뤄보는데 어디를 고쳐야할지 통 모르겠습니다...
글쓴이: majesticer13 / 작성시간: 수, 2019/10/23 - 9:06오후
워드프레스에 로그인, 검색, sns 기능을 넣는 헤더를 추가하는 중인데 로그인 폼 부분에서 계속 오류가 발생합니다.
먼저 정상 작동하는 코드입니다.
<div class="container" > <table border="0" width="100%"> <tr> <td width="13%"> <?php wp_nav_menu( array( 'theme_location' => 'login-menu_1' ) ); ?> </td> <td width="13%"> <?php wp_nav_menu( array( 'theme_location' => 'login-menu_2' ) ); ?> </td> <td width="48%"> <form role="search" method="get" class="search-form" action="http://183.111.125.81/"> <label> <span class="screen-reader-text">다음 검색:</span> <input type="search" class="search-field" placeholder="검색 …" value="" name="s"> </label> </form> </td> <td width="26%"> <a href = <a href="https://www.facebook.com/rheeyeunghui/><font" rel="nofollow">https://www.facebook.com/rheeyeunghui/><font</a> color=#000000><img src='wp-content/uploads/2019/10/페이스북.png'></font></a> <a href = <a href="https://twitter.com/rheeyeunghui?lang=ko><font" rel="nofollow">https://twitter.com/rheeyeunghui?lang=ko><font</a> color=#000000><img src='wp-content/uploads/2019/10/트위터.png'></font></a> <a href = <a href="https://www.youtube.com/user/rheeyeunghui><font" rel="nofollow">https://www.youtube.com/user/rheeyeunghui><font</a> color=#000000><img src='wp-content/uploads/2019/10/유튜브.png'></font></a> <a href = <a href="https://www.flickr.com/people/rheeyeunghui/><font" rel="nofollow">https://www.flickr.com/people/rheeyeunghui/><font</a> color=#000000><img src='wp-content/uploads/2019/10/플리커.png'></font></a> </td> </tr> </table> </div>
이렇게 할 경우 모바일에서 로그인·회원가입 버튼이 세로로 출력되기에 if문을 검색해서 적용해 봤는데 여기서 문제가 발생했습니다.
<?php $com_header=<<<eot <div class="container" > <table border="0" width="100%"> <tr> <td width="13%"> <?php wp_nav_menu( array( 'theme_location' => 'login-menu_1' ) ); ?> </td> <td width="13%"> <?php wp_nav_menu( array( 'theme_location' => 'login-menu_2' ) ); ?> </td> <td width="48%"> <form role="search" method="get" class="search-form" action="http://183.111.125.81/"> <label> <span class="screen-reader-text">다음 검색:</span> <input type="search" class="search-field" placeholder="검색 …" value="" name="s"> </label> </form> </td> <td width="26%"> <a href = <a href="https://www.facebook.com/rheeyeunghui/><font" rel="nofollow">https://www.facebook.com/rheeyeunghui/><font</a> color=#000000><img src='wp-content/uploads/2019/10/페이스북.png'></font></a> <a href = <a href="https://twitter.com/rheeyeunghui?lang=ko><font" rel="nofollow">https://twitter.com/rheeyeunghui?lang=ko><font</a> color=#000000><img src='wp-content/uploads/2019/10/트위터.png'></font></a> <a href = <a href="https://www.youtube.com/user/rheeyeunghui><font" rel="nofollow">https://www.youtube.com/user/rheeyeunghui><font</a> color=#000000><img src='wp-content/uploads/2019/10/유튜브.png'></font></a> <a href = <a href="https://www.flickr.com/people/rheeyeunghui/><font" rel="nofollow">https://www.flickr.com/people/rheeyeunghui/><font</a> color=#000000><img src='wp-content/uploads/2019/10/플리커.png'></font></a> </td> </tr> </table> </div> eot; $phone_header=<<<eot <div class="container" > <table border="0" width="100%"> <tr> <td width="26%"> <tr> <?php wp_nav_menu( array( 'theme_location' => 'login-menu_1' ) ); ?> </tr> <tr> <?php wp_nav_menu( array( 'theme_location' => 'login-menu_2' ) ); ?> </tr> <td> <td width="48%"> <form role="search" method="get" class="search-form" action="http://183.111.125.81/"> <label> <span class="screen-reader-text">다음 검색:</span> <input type="search" class="search-field" placeholder="검색 …" value="" name="s"> </label> </form> </td> <td width="26%"> <a href = <a href="https://www.facebook.com/rheeyeunghui/><font" rel="nofollow">https://www.facebook.com/rheeyeunghui/><font</a> color=#000000><img src='wp-content/uploads/2019/10/페이스북.png'></font></a> <a href = <a href="https://twitter.com/rheeyeunghui?lang=ko><font" rel="nofollow">https://twitter.com/rheeyeunghui?lang=ko><font</a> color=#000000><img src='wp-content/uploads/2019/10/트위터.png'></font></a> <a href = <a href="https://www.youtube.com/user/rheeyeunghui><font" rel="nofollow">https://www.youtube.com/user/rheeyeunghui><font</a> color=#000000><img src='wp-content/uploads/2019/10/유튜브.png'></font></a> <a href = <a href="https://www.flickr.com/people/rheeyeunghui/><font" rel="nofollow">https://www.flickr.com/people/rheeyeunghui/><font</a> color=#000000><img src='wp-content/uploads/2019/10/플리커.png'></font></a> </td> </tr> </table> </div> eot; if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false ) { print $phone_header; } else { print $com_header; } ?>
이렇게 하니 로그인 부분이 정상 출력이 되지 않고
'login-menu_1' ) ); ?> 'login-menu_2' ) ); ?>
이런 식으로 코드 일부가 나타나내요...
eot사용하지 않고 그냥 넣으면 아예 페이지가 뜨질 않으니 어떻게 손봐야 할지 모르겠습니다.
도움이나 조언 부탁드립니다.
현재 아래의 문제 코드 적용된 사이트 주소입니다.
http://183.111.125.81/
Forums:
원인 자체는 간단합니다.
원인 자체는 간단합니다.
do_something 함수가 호출이 될까요 안될까요? 직접 테스트해보세요.
print $com_header;
가 거의 비슷한 삽질을 하고 있습니다. 찾아보세요.문제를 어떻게든 해결하는 방법은 여럿 있겠지만, 솔직히 저는 웹 문서 (거의) 전체를 php 문자열에 담아뒀다가 출력한다는 방법 자체에 거부감이 좀 느껴집니다. 이게 그렇게까지 해야 될 문제인가요?
힌트 감사합니다.
덕분에 문제 해결 했습니다!! 충고와 힌트에 감사드립니다.
댓글 달기