Continuo recebendo este erro quando estava em uma configuração LEMP nginx 1.10/PHP 7 e pensei que era por causa do PHP 7 e agora configurei um novo servidor com nginx 1.4.6/PHP 5.5.9
2016/06/19 15:45:18 [error] 4094#0: *1 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected end of file in /var/www/www.example.com/public/wp-content/themes/techs/functions.php on line 141" while reading response header from upstream, client: 10.0.0.11, server: www.example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com"
Agora, o arquivo que está causando esse erro está aqui e notei que a linha é a última linha vazia e tentei removê-la, mas não foi removida. Alguém pode me indicar o que está causando esse erro?
nano /var/www/www.example.com/public/wp-content/themes/techs/functions.php
a linha 141 é a linha vazia após/sob a tag de fechamento; todas as tentativas de excluir essa linha falharam
<?php
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 75, 56, true ); // Normal post thumbnails
add_image_size( 'single-post-thumbnail', 273, 273 ); // Permalink thumbnail size
}
/*register_sidebar(array(
'name'=>'sidebar',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
*/
# Displays a list of popular posts
function gtt_popular_posts($num, $pre='<li>', $suf='</li>', $excerpt=true) {
global $wpdb;
$querystr = "SELECT $wpdb->posts.post_title,$wpdb->posts.post_date_gmt, $wpdb->posts.ID, $wpdb->posts.post_content FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ORDER BY $wpdb->posts.comment_count DESC LIMIT $num";
$myposts = $wpdb->get_results($querystr, OBJECT);
foreach($myposts as $post) {
echo $pre;
?><div class="fpimg">
<img src="<?php get_post_thumbnail($post->ID); ?>" />
</div>
<div class="fpost">
<a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title ?></a><br />
<?php if (function_exists('time_since')) {echo time_since(abs(strtotime($post->post_date_gmt . " GMT")), time()) . " ago";} else {the_time('F jS, Y');} ?>
</div>
<?php echo $suf;
}
}
function get_recent_posts($num) {
$recent_posts = wp_get_recent_posts($num);
foreach($recent_posts as $post){
?>
<li><div class="fpimg"> <?php echo '<a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >'; ?>
<img src="<?php get_post_thumbnail($post["ID"]); ?>" />
</div>
<div class="fpost">
<?php echo '<a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' . $post["post_title"].'</a> ';?>
<br />
<?php if (function_exists('time_since')) {echo time_since(abs(strtotime($post["post_date_gmt"] . " GMT")), time()) . " ago";} else {the_time('F jS, Y');} ?>
</div>
</li>
<? }
}
function time_since($older_date, $newer_date = false)
{
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
// $newer_date will equal false if we want to know the time elapsed between a date and the current time
// $newer_date will have a value if we want to work out time elapsed between two known dates
$newer_date = ($newer_date == false) ? (time()+(60*60*get_settings("gmt_offset"))) : $newer_date;
// difference in seconds
$since = $newer_date - $older_date;
// we only want to output two chunks of time here, eg:
// x years, xx months
// x days, xx hours
// so there's only two bits of calculation below:
// step one: the first chunk
for ($i = 0, $j = count($chunks); $i < $j; $i++)
{
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
// finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0)
{
break;
}
}
// set output var
$output = ($count == 1) ? '1 '.$name : "$count {$name}s";
// step two: the second chunk
if ($i + 1 < $j)
{
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
{
// add to output var
$output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
}
}
return $output;
}
function get_post_thumbnail($pid) {
$files = get_children('post_parent='.$pid.'&post_type=attachment&post_mime_type=image');
if($files) :
$keys = array_reverse(array_keys($files));
$j=0;
$num = $keys[$j];
$image=wp_get_attachment_image($num, 'large', false);
$imagepieces = explode('"', $image);
$imagepath = $imagepieces[1];
$thumb=wp_get_attachment_thumb_url($num);
print $thumb;
else:
echo bloginfo('template_directory')."/images/smallimg.jpg";
endif;
}
function get_post_thumbnails() {
$files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
if($files) :
$keys = array_reverse(array_keys($files));
$j=0;
$num = $keys[$j];
$image=wp_get_attachment_image($num, 'large', false);
$imagepieces = explode('"', $image);
$imagepath = $imagepieces[1];
$thumb=wp_get_attachment_thumb_url($num);
print $thumb;
else:
echo bloginfo('template_directory')."/images/smallimg.jpg";
endif;
}
?>
Aparentemente, seu problema está na tag curta de abertura
<?
próxima ao final daget_recent_posts()
função.Mude para
<?php
e esse problema desaparecerá.Da próxima vez que você tiver erros de programação, consulte http://stackoverflow.com .
Ok, aqui está o que eu fiz e o erro desapareceu
editei o arquivo php.ini
nano /etc/php5/fpm/php.ini
e fiz essa mudança, basicamente mudei de desligado para ligado
Em vez disso, gostaria de saber de que outra forma resolver esse erro
Obrigado
ATUALIZAÇÃO: isso só funcionou para o PHP 5.5.9, mas não funcionou para o PHP 7.0.4 Então ainda gostaria de resolvê-lo da melhor maneira