2011-02-08 44 views
1

我需要編寫一個函數,它定義了一個帶有html標記的變量,現在在這個html標記中,我需要包含一個必須通過鉤子傳遞給我的瀏覽器的php代碼片段。在我的span標籤中,我需要php代碼片段才能正確輸出。如何寫入一個PHP函數,該函數定義了一個包含html和php的變量?

的PHP代碼片段是這樣的

<?php gravity_form(1, true, true, false, '', true); ?> 

我的作用是低於通知PHP代碼片段是如何被格式化,我需要找出如何正確格式化。

function html_fxcntab_hidden_gform() { 

    $html_fxcntab_hidden_gform_div = "<span style= \"display:none\";> <?php gravity_form(1, true, true, false, '', true); ?> </span>"; 

    echo $html_fxcntab_hidden_gform_div; 
} 

add_action('wp_footer', 'html_fxcntab_hidden_gform'); 

謝謝,

邁克爾Sablatura

+1

使用級聯` '的'。 myFunction(1,true,false)。 '';` – Pablo 2011-02-08 04:15:21

+0

如果`gravity_form`顯示它的輸出而不是返回它,它可能不會。他不得不使用輸出緩衝; @伊格納西奧的答案更簡單。 – 2011-02-08 04:18:07

回答

1
function html_fxcntab_hidden_gform() { 
?> 
    <span style="display:none"> <?php gravity_form(1, true, true, false, '', true); ?> </span><?php 
} 
相關問題