问题描述
我正在使用运行在PHP 5.3.5的XAMPP服务器上的CakePHP,我一直收到错误消息
语法错误,意外的T_CONSTANT_ENCAPSED_STRING行38
第38行是'b'b
< div id ='发布',
center_content >
< h2>发布列表< / h2>
< p>以下是现有帖子的列表< / p>
< div>
< / div>
<?php
if(isset($ posts)&&& is_array($ posts))
{
?>
< table>
< tr>
< td>
< b> ID< / b>
< / td>
< td>
< b>标题< / b>
< / td>
< td>
< b>内容< / b>
< / td>
< td>
< b>上次修改日期< / b>
< / td>
< td>已发布
< b>< b>
< / td>
< td colspan =2>< b>& nbsp;& nbsp;动作< / b>< / td>
< / tr>
<?php foreach($ posts as $ post):?>
< tr>
< td><?php echo $ post ['Post'] ['id'];?>< / td>
< td><?php echo $ post ['Post'] ['title'];?>< / td>
< td><?php echo $ post ['Post'] ['content'];?>< / td>
< td><?php echo $ post ['Post'] ['modified'];?>< / td>
< td>
<?php echo $ html->链接(ife(
$ post ['Post'] ['published'] == 1',
'Published',
'Unpublished),
'/posts/'.ife($post['Post']['published'] == 1',
'disabled','enable')。'/' 。$ post ['Post'] ['id']
);
?>
< / td>
< td>
<?php echo $ html->链接(
'编辑',
'/posts/edit'.$post['Post']['id']);? >
< / td>
< td>
<?php echo $ html-> link(
'Delete',
'/posts/delete/'.$post['Post']['id']); ?>
< / td>
< / tr>
if(sizeof($ posts)== 0){
?>
< tr style =background-color:#cccccc;>
< td colspan =6>
< span style =font-size:17px;>
找不到帖子。
< / span>
< / td>
< / tr>
<?php
}
?>
< / table>
< br />
<?php
}
?>
< / div>
这就是所有,请注意,使用CakePHP MVC框架使用PHP 5.3.5运行应用程序
将其从
更改为 < ?php echo $ html-> link(ife(
'$ post ['Post'] ['published'] == 1',
'Published',
'Unpublished') ,
'/posts/'.ife('$post'['Post']['published'] == 1',
'disabled','enable')。'/'。$ post ['Post'] ['id']
);
?>
至
<?php echo $ html->链接(ife(
$ post ['Post'] ['published'] == 1',
'Published',
'Unpublished),
'/posts/'.ife($post['Post']['published'] == 1',
'disabled','enable)。'/'。 $ post ['Post'] ['id']
);
?>
您只需在$ post
之前删除单引号
Am using CakePHP running on XAMPP Server with PHP 5.3.5 i keep getting the error message syntax error, unexpected T_CONSTANT_ENCAPSED_STRING Line 38
Line 38 is 'Published',
The Code
<div id="center_content">
<h2>Post Listings</h2>
<p>Here is a list of existing posts</p>
<div>
</div>
<?php
if (isset($posts) && is_array($posts))
{
?>
<table>
<tr>
<td>
<b>ID</b>
</td>
<td>
<b>title</b>
</td>
<td>
<b>content</b>
</td>
<td>
<b>Last Modified</b>
</td>
<td>
<b>published<b>
</td>
<td colspan="2"><b> Action</b></td>
</tr>
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id'];?></td>
<td><?php echo $post['Post']['title'];?></td>
<td><?php echo $post['Post']['content'];?></td>
<td><?php echo $post['Post']['modified'];?></td>
<td>
<?php echo $html->link(ife(
$post['Post']['published'] == 1',
'Published',
'Unpublished),
'/posts/'.ife($post['Post']['published'] == 1',
'disabled','enable').'/'.$post['Post']['id']
);
?>
</td>
<td>
<?php echo $html->link(
'Edit',
'/posts/edit'.$post['Post']['id']);?>
</td>
<td>
<?php echo $html->link(
'Delete',
'/posts/delete/'.$post['Post']['id']);?>
</td>
</tr>
<? endforeach; ?>
<?php
if (sizeof($posts) == 0) {
?>
<tr style= "background-color:#cccccc;">
<td colspan="6">
<span style="font-size: 17px;">
No post found.
</span>
</td>
</tr>
<?php
}
?>
</table>
<br/>
<?php
}
?>
</div>
Thats all, Note am running the app with PHP 5.3.5 using CakePHP MVC Framework
Change it from
<?php echo $html->link(ife(
'$post['Post']['published'] == 1',
'Published',
'Unpublished'),
'/posts/'.ife('$post'['Post']['published'] == 1',
'disabled','enable').'/'.$post['Post']['id']
);
?>
to
<?php echo $html->link(ife(
$post['Post']['published'] == 1',
'Published',
'Unpublished),
'/posts/'.ife($post['Post']['published'] == 1',
'disabled','enable).'/'.$post['Post']['id']
);
?>
You just needed to remove the single quote right before $post
这篇关于意外的T_CONSTANT_ENCAPSED_STRING的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!