php 처음 다뤄보는데 어디를 고쳐야할지 통 모르겠습니다...

majesticer13의 이미지

워드프레스에 로그인, 검색, 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/

익명 사용자의 이미지

원인 자체는 간단합니다.

<?php print "<?php do_something(); ?>"; ?>

do_something 함수가 호출이 될까요 안될까요? 직접 테스트해보세요.

print $com_header;가 거의 비슷한 삽질을 하고 있습니다. 찾아보세요.

문제를 어떻게든 해결하는 방법은 여럿 있겠지만, 솔직히 저는 웹 문서 (거의) 전체를 php 문자열에 담아뒀다가 출력한다는 방법 자체에 거부감이 좀 느껴집니다. 이게 그렇게까지 해야 될 문제인가요?

majesticer13의 이미지

덕분에 문제 해결 했습니다!! 충고와 힌트에 감사드립니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.