php Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING [duplicate]

StackOverflow https://stackoverflow.com/questions/23409929

  •  13-07-2023
  •  | 
  •  

سؤال

New to PHP. Having a problem with a "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING"

Here is the code:

<?php 
$moreLink = '';
if ($data->node_type == "product_book") :
$path = str_replace(' ', '-', strtolower($data->node_title));
$moreLink = '<a href="/books/'.$path'">Read more > </a>';
else :
$path = drupal_get_path_alias( 'node/' . $data->nid);
$moreLink = '<a href="/'.$path.'">Read more > </a>';
endif;
return $moreLink;
?>

Any help would be greatly appreciated. Thanks. -Matt

هل كانت مفيدة؟

المحلول

You forget a . on this line:

$moreLink = '<a href="/books/'.$path'">Read more > </a>';

It should be

$moreLink = '<a href="/books/'.$path.'">Read more > </a>';
                                    ^ here
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top