2015-05-14 36 views
-2

我有这样的代码:什么是错的代码PHP

<div class="gigel"><?php 
    // In case there is opening and closing shortcode. 
    echo do_shortcode('[woocs show_flags=1 width='300px' flag_position='right']'); 
    ?></div> 

这是简码:

[woocs show_flags=1 width='300px' flag_position='right'] 

这是错误:

Parse error: syntax error, unexpected '300' (T_LNUMBER) in /home/dacproie/public_html/test2/wp/wp-content/themes/mix/header.php on line 189 

我怎样才能解决这个问题问题?

在此先感谢!

回答

4

只需更改下面的代码与

<div class="gigel"><?php 
// In case there is opening and closing shortcode. 
echo do_shortcode("[woocs show_flags=1 width='300px' flag_position='right']"); 
?></div> 

我希望这是为你工作。

+2

你是对的,当然,但你可能要解释为什么对OP为好。 –

0

请尝试清洁你的代码

<?php 
    $forHtml = do_shortcode("[woocs show_flags=1 width='300px' flag_position='right']"); 
?> 

<!-- separate your layers --> 

<div class="gigel"><?php 
    <?php print ("%s", $forHtml); ?> 
?></div> 
0

总是尝试当你不得不使用do_shortcode()函数中使用双引号。

所以使用双引号,而不是单引号的解决您的问题,你需要修改它像:

<div class="gigel"> 
<?php 
    echo do_shortcode("[woocs show_flags=1 width='300px' flag_position='right']"); 
    ?> 
</div>