2015-02-09 219 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');