2015-02-09 48 views
-5

任何人都知道我在這裏做錯了嗎?我有一個Wordpress兒童主題中的functions.php文件中的代碼。PHP的幫助?解析錯誤:語法錯誤,第6行的意外T_STRING

<?php 
function my_password_form() { 
global $post; 
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); 
$o = '<form action="' . esc_url(site_url('wp-login.php?action=postpass', 'login_post')) . '" method="post"> 
' . __("This content is CLASSIFIED, for subscribers only! To get access, <a href="http://maryefern.com/join">join here</a>, check your e-mail for a message from me with the password, and enter it below:") . ' 
<label for="' . $label . '">' . __("Password:") . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__("Submit") . '" /> 
</form> 
'; 
return $o; 
} 
add_filter('the_password_form', 'my_password_form'); 
?> 
+4

看語法高亮,你會看到。 – ceejayoz 2015-02-09 21:03:44

回答

0

該錯誤通常意味着你有一些文本(字符串)不應該在哪裏。當我得到這個錯誤,這意味着我可能沒有正確逃脫或沒有正確跳入/跳出。

爲了儘量減少這種情況,我將標記/輸出分隔成不同的行。確保它使代碼更長(更多線條),但它有助於保持直線。

我不知道這段代碼是否有效,但至少你的錯誤消失了。 @ceejayoz是正確的,語法突出顯示應該可以幫助你。

PHP

function my_password_form() { 
     global $post; 
     $label = 'pwbox-' . (empty($post->ID) ? rand() : $post->ID); 

     $o = '<form action="' . esc_url(site_url('wp-login.php?action=postpass', 'login_post')) . '" method="post">'; 
     $o .= '(This content is CLASSIFIED, for subscribers only! To get access, <a href="http://maryefern.com/join">join here</a>, check your e-mail for a message from me with the password, and enter it below:)'; 
     $o .= '<label for="' . $label . '">' . ("Password:") . '</label>'; 
     $o .= '<input name = "post_password" id = "' . $label . '" type = "password" size = "20" maxlength = "20" /><input type = "submit" name = "Submit" value = "' . esc_attr__("Submit") . '" />'; 
     $o .= '</form>'; 

     return $o; 
} 

add_filter('the_password_form', 'my_password_form'); 
相關問題