Home  >  Article  >  Backend Development  >  PHP does not support attribute value problem

PHP does not support attribute value problem

WBOY
WBOYOriginal
2016-08-18 09:15:411335browse

When rewriting the theme, I encountered a rather annoying problem:

<code> <li><a class="active" href="#"></a></li></code>

If this code is inserted into the PHP file, an error will be reported:

[16-Aug-2016 13:45:49 UTC] PHP Parse error: syntax error, unexpected 'active' (T_STRING), expecting ',' or ';' in /home/sunhbjaq/public_html/site/snippets/ sidebar.php on line 17

After removing class="active", it will return to normal.
How to solve it? Thanks. (Newbie, please answer patiently, thank you very much!)
Note: Full text of sidebar.php:

<code><body><!-- header -->            <section id="header">                <header>                    
<span class="image avatar"><img src="<?php echo html($site->authoravatarurl()) ?>" alt="<?php echo html($site->description()) ?>" /></span>                    
<h1 id="logo"><a href="<?php echo $site->authorurl>"><?php echo html($site->author()) ?></a></h1>                    <p><?php echo html($site->authorintroduction()) ?></p>                
</header>
<!-- /header 下面为id-->   <nav>         
<ul>          
<?php foreach($pages->visible() as $p): ?>          <?php if ($p->isOpen()): ?>              <li><a class="active" href="#"></a></li>          <?php else: ?>              <li><a href="<?php echo html($p->url()) ?>"></a></li>          <?php endif; ?>          <?php endforeach ?>      </ul>   </nav>   <footer>                    <ul class="icons">                        <li><a href="#" class="icon fa-twitter"><span class="label">Twitter</span></a></li>                        <li><a href="#" class="icon fa-facebook"><span class="label">Facebook</span></a></li>                        <li><a href="#" class="icon fa-instagram"><span class="label">Instagram</span></a></li>                        <li><a href="#" class="icon fa-github"><span class="label">Github</span></a></li>                        <li><a href="#" class="icon fa-envelope"><span class="label">Email</span></a></li>                    </ul>     </footer></section></code>

Reply content:

When rewriting the theme, I encountered a rather annoying problem:

<code> <li><a class="active" href="#"></a></li></code>

If this code is inserted into the PHP file, an error will be reported:

[16-Aug-2016 13:45:49 UTC] PHP Parse error: syntax error, unexpected 'active' (T_STRING), expecting ',' or ';' in /home/sunhbjaq/public_html/site/snippets/ sidebar.php on line 17

After removing class="active", it will return to normal.
How to solve it? Thanks. (Newbie, please answer patiently, thank you very much!)
Note: Full text of sidebar.php:

<code><body><!-- header -->            <section id="header">                <header>                    
<span class="image avatar"><img src="<?php echo html($site->authoravatarurl()) ?>" alt="<?php echo html($site->description()) ?>" /></span>                    
<h1 id="logo"><a href="<?php echo $site->authorurl>"><?php echo html($site->author()) ?></a></h1>                    <p><?php echo html($site->authorintroduction()) ?></p>                
</header>
<!-- /header 下面为id-->   <nav>         
<ul>          
<?php foreach($pages->visible() as $p): ?>          <?php if ($p->isOpen()): ?>              <li><a class="active" href="#"></a></li>          <?php else: ?>              <li><a href="<?php echo html($p->url()) ?>"></a></li>          <?php endif; ?>          <?php endforeach ?>      </ul>   </nav>   <footer>                    <ul class="icons">                        <li><a href="#" class="icon fa-twitter"><span class="label">Twitter</span></a></li>                        <li><a href="#" class="icon fa-facebook"><span class="label">Facebook</span></a></li>                        <li><a href="#" class="icon fa-instagram"><span class="label">Instagram</span></a></li>                        <li><a href="#" class="icon fa-github"><span class="label">Github</span></a></li>                        <li><a href="#" class="icon fa-envelope"><span class="label">Email</span></a></li>                    </ul>     </footer></section></code>

This is a syntax error. Please upload the code. Thank you.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn