2015-05-14 37 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>