我添加链接并得到错误解析错误:语法错误


I add link and get error Parse error: syntax error

我已经尽力了,只是运气不好。

错误提示:解析错误:语法错误,意想不到的T_STRING,期待','

                                <?php
echo '<a style="cursor: pointer"  onclick="javascript: window.location = ''fruit_list.php?do=delete&id=<?php print $fruitdata['id']; ?>/'';">Delete</a>';?>

您必须从命令中删除<?php print ...部分:

echo '<a style="cursor: pointer"  onclick="javascript: window.location = ''fruit_list.php?do=delete&id=' . $fruitdata['id'] . ''';">Delete</a>';?>

请注意,如果将代码分成两行,可能会更容易阅读:

$action = "window.location = 'fruit_list.php?do=delete&id={$fruitdata['id']}";
echo '<a style="cursor: pointer" onclick="javascript:' . $action . '">Delete</a>';
<?php echo '<a style="cursor: pointer"  onclick="javascript: window.location = ''fruit_list.php?do=delete&id='.$fruitdata['id'].''';">Delete</a>';?>