解析错误:语法错误,意外 T_STRING 59 [英] Parse error: syntax error, unexpected T_STRING 59 查看:33 发布时间:2021/9/3 20:42:45 php syntax-error 本文介绍了解析错误:语法错误,意外 T_STRING 59的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 请修复这段代码.这就是它所说的解析错误:语法错误,第 49 行/home/timmycpc/public_html/ItemDatabase/index.php 中的意外 T_STRING"这是第 12 - 49 行: 解决方案 您的线路 $str ... 正在进入和退出 PHP 字符串.这导致解析错误.您必须转义 \" 引号、连接字符串或使用 HEREDDoc.有关详细信息,请参阅PHP 字符串手册.>选项 1:(最佳) 您可以对字符串中的双引号进行转义:(并删除 <?php echo)$str .= "</td><td style='text-align: left !important;><b>名称:</b> $label</td><td><b>项目 ID:</b>$id</td><td><b>会员:</b>$member</td><td><b>费用:</b>$costcoin<;/td><td><b>已修补:</b>$patched</td></tr>";选项 2: 连接字符串并使用单引号:$str .='<tr><td><embed src="http://www.url.com/SWFViewer/items.swf?id='.$id.'"></td><td style="text-align: left !important;"><b>名称:</b>' .$标签.'</td><td><b>项目 ID:</b>' .$id .'</td><td><b>成员:</b>' .$会员.'</td><td><b>成本:</b>' .$成本.'硬币</td><td><b>补丁:</b>' .$修补.'</td></tr>';选项 3:(最慢)使用 HereDoc:$str .= <<<EOF<tr><td><embed src="http://www.url.com/SWFViewer/items.swf?id=$id"></td><td style="text-align: left !important;"><b>名称:</b>$label</td><td><b>项目 ID:</b>$id</td><td><b>成员:</b>$member</td><td><b>费用:</b>$cost币</td><td><b>补丁:</b>$patched</td></tr>EOF;Please fix this piece of coding. This is what it says "Parse error: syntax error, unexpected T_STRING in /home/timmycpc/public_html/ItemDatabase/index.php on line 49"This is line 12 - 49:<?php $arr = json_decode(file_get_contents("url.com/file.json"),true); $page = isset($_GET['p']) ? intval($_GET['p']) : 0; $elementsPerPage = 20; $elements = array_slice($arr, $page * $elementsPerPage, $elementsPerPage); $totalpages = intval(count($arr)/$elementsPerPage); if($_GET['p'] == ""){$_GET['p'] = '0';} $whatpage = $_GET['p']; if($whatpage > $totalpages){echo("<tr><td>Sorry this page does not exist. Please return to <a href='?p=0'>page 1</a>.</td></tr>"); exit;} $link1 = $whatpage-1; $link2 = $whatpage+1; if($_GET['p'] == 0){$backbutton = "";} else {$backbutton = "<a href=?p=" . $link1 . ">Previous Page</a>";} if($_GET['p'] == $totalpages){$nextbutton = "";} else {$nextbutton = "<a href=?p=" . $link2 . ">Next Page</a>";} if($_GET['p'] == $totalpages or $_GET['p'] == 0){$middle = "";} else {$middle = " | ";} $pagenav = $backbutton . $middle . $nextbutton; echo('<tr><td colspan="5" align="center">'.$pagenav.'</td></tr>'); foreach($elements as $item) { $label = $item['label']; $cost = $item['cost']; $id = $item['paper_item_id']; $member = $item['is_member']; $patched = $item['is_bait']; if ($member == "1") { $member = "Yes"; }else{ $member = "No"; } if ($patched == "1") { $patched = "Yes"; }else{ $patched = "No"; } $str .= "<tr><td><embed src="http://www.url.com/SWFViewer/items.swf?id=<?php echo($id); ?>"></td><td style='text-align: left !important;'><b>Name:</b> $label</td><td><b>Item ID:</b> $id</td><td><b>Members:</b> $member</td><td><b>Cost:</b> $cost coins</td><td><b>Patched:</b> $patched</td></tr>"; } echo substr($str, 0, -5); ?></table></center></body></html> 解决方案 Your line $str ... is breaking in and out of a PHP String. Which is causing the parse error. You have to either escape \" quotes, concatenate your strings, or use a HEREDoc. See the PHP Manual on Strings for more information. Option 1: (Best) You can escape the double quotes within your string: (And remove the <?php echo)$str .= "<tr><td><embed src=\"http://www.url.com/SWFViewer/items.swf?id=$id\"></td><td style='text-align: left !important;'><b>Name:</b> $label</td><td><b>Item ID:</b> $id</td><td><b>Members:</b> $member</td><td><b>Cost:</b> $cost coins</td><td><b>Patched:</b> $patched</td></tr>"; Option 2: Concatenate your string and use single quotes:$str .= '<tr><td><embed src="http://www.url.com/SWFViewer/items.swf?id=' . $id . '"></td><td style="text-align: left !important;"><b>Name:</b> ' . $label . '</td><td><b>Item ID:</b> ' . $id . '</td><td><b>Members:</b> ' . $member . '</td><td><b>Cost:</b> ' . $cost . ' coins</td><td><b>Patched:</b> ' . $patched . '</td></tr>'; Option 3: (Slowest) Use a HereDoc:$str .= <<<EOF <tr><td><embed src="http://www.url.com/SWFViewer/items.swf?id=$id"></td><td style="text-align: left !important;"><b>Name:</b> $label</td><td><b>Item ID:</b> $id</td><td><b>Members:</b> $member</td><td><b>Cost:</b> $cost coins</td><td><b>Patched:</b> $patched</td></tr> EOF; 这篇关于解析错误:语法错误,意外 T_STRING 59的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 查看全文 相关文章 帮助查找“解析错误:语法错误,意外T_STRING”; 解析错误:语法错误,意外的'对象'(T_STRING),期待')'; 解析错误:语法错误,意外'array_push'(T_STRING); 解析错误:语法错误,意外T_ENCAPSED_AND WHITESPACE,期待T_STRING; 解析错误:语法错误,意外(T_STRING),预期变量(T_VARIABLE); 解析错误:语法错误,意外的'mysql_query'(T_STRING)in; 解析错误:语法错误,意外的'mysqli_query'(T_STRING); 解析错误:语法错误,PHP中出现意外的T_STRING; 错误解析错误:语法错误,意外的T_STRING,期待T_CONSTANT_ENCAPSED_STRING; 错误解析错误:语法错误,意外的T_STRING,预期的T_CONSTANT_ENCAPSED_STRING; 语法错误,INSERT命令上的意外T_STRING; 语法错误,意外的"mysql_connect"(T_STRING); 解析错误:语法错误,意外的“<”,预期为T_STRING或T_VARIABLE; PHP不喜欢这个T_String. (语法错误意外T_STRING); 语法错误,意外的T_GOTO,预期为T_STRING; Laravel 解析错误:语法错误,意外的 T_CLASS,期待 T_STRING 或 T_VARIABLE; 解析错误:语法错误,意想不到的T_STRING; PHP解析错误-意外的T_STRING; 输出缓冲,解析错误意外t_string; Laravel解析错误:语法错误,意外的T_CLASS,预期的T_STRING或T_VARIABLE; 获取名称空间行意外的语法错误T_STRING; 我得到了这个Parse错误:语法错误,意外的T_STRING,期待'('in; 解析错误:语法错误,意外的'__construct'(T_STRING),期望函数(T_FUNCTION)或const(T_CONST); 解析错误:语法错误,文件意外结束 - 第 59 行; PHP 解析错误:语法错误,意外的 T_ENCAPSED_AND_WHITESPACE,期待 T_STRING 或 T_VARIABLE 或 T_NUM_STRING; PHP最新文章 请求头字段Access-Control-Allow-Headers在预检响应中不允许Access-Control-Allow-Headers; 路由问题导致Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException错误; 什么是NCFB和NOFB模式?; 警告:mysqli_connect():(HY000 / 1045):访问被拒绝用户'用户名'@'localhost'(使用密码:是); 如何处理致命错误:cURL错误7:无法连接到xxxx端口443; 参数3传递给GuzzleHttp\Client :: request()必须是数组类型,给定字符串; phpMyAdmin的#2054无法登录到MySQL服务器; SSL错误SSL3_GET_SERVER_CERTIFICATE:证书验证失败; 在PHPExcel中设置字体颜色,字体和字体大小; 如何解决cURL错误(7):无法连接到主机?; 热门教程 Java教程 Apache ANT 教程 Kali Linux教程 JavaScript教程 JavaFx教程 MFC 教程 Apache HTTP客户端教程 Microsoft Visio 教程 热门工具 Java 在线工具 C(GCC) 在线工具 PHP 在线工具 C# 在线工具 Python 在线工具 MySQL 在线工具 VB.NET 在线工具 Lua 在线工具 Oracle 在线工具 C++(GCC) 在线工具 Go 在线工具 Fortran 在线工具 登录 关闭 扫码关注1秒登录 发送“验证码”获取 | 15天全站免登陆