【问题标题】:Removing empty lines with notepad++ causes T_Variable Syntax Error使用 notepad++ 删除空行会导致 T_Variable 语法错误
【发布时间】:2014-03-24 10:17:02
【问题描述】:

Removing empty lines in Notepad++

如上述线程中所述,您可以使用 notepad++ 删除空行。我确实尝试了这些方法,但我总是收到奇怪的 T_Variable 语法错误(主要在第 1-6 行)。这些行肯定没有错误,我在任何地方都看不到。

当我手动删除代码某些区域的空行(例如前 5 行)时,也会发生这种情况。我猜这是一个编码问题,但在 UTF-8、Ascii 等中重新编码也没有帮助。

几个月前我使用网络托管商的在线编辑器时添加了这些行(之前的行之间有一个空行)。

我不明白,也许你明白(提前感谢!)。该文件位于http://lightningsoul.com/index.php

这是第一段代码:

<?php

 include("db/lg_db_login.php"); 
//require 'fb/facebook.php';
 if (isset($_GET['c'])) { $content = $_GET['c']; }
 else { $content = ""; } 
 if (isset($_GET['sc'])) { $subcontent = $_GET['sc']; }
 else { $subcontent = ""; }
 if (isset($_GET['setlang'])) { $setlang = $_GET['setlang']; }
 else { $setlang = "eng"; } 
 $cat = $_GET['cat'];

// Check if Lightningsoul.de or .com
 $findme   = '.de';
 $posde = strpos($thisurl, $findme);

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($posde === false) {
    $lang = "en";
} else {
    $lang = "de";
}
 include("db/pageturn_class.php"); 

$findStr   = '/lightningsoulcom';
$isApp = strpos($thisurl, $findStr);

// Beachten Sie die Verwendung von ===. Ein einfacher Vergleich (==) liefert
// nicht das erwartete Ergebnis, da die Position von 'a' die nullte Stelle
// (also das erste Zeichen) ist
/*if ($isApp == false) {
    $getStyle = "css/get_style.php";
} else {
   $getStyle = "css/get_style_small.php";
} */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

【问题讨论】:

  • 首先,为什么要删除空行?在你的代码的哪一部分?如果它在&lt;?php ?&gt; 中,则没有必要。删除空行是有用的(相对地......)你使你的 html 输出更轻。 php 部分永远不会在 HTML 上呈现,si 是否有 emply 行并不重要,它只是让开发人员更容易阅读。
  • 除了上面的建议。 “不要删除空行。代码的可读性是重中之重!”你检查修改后的文件了吗?它看起来像什么?
  • lightningsoul.com/private/img/empty_lines.png 因为代码看起来像这样。在使代码可读的正常空行之间还有另一个空行。也许您应该阅读我在原帖中写的内容?!
  • ToBe:修改了什么文件?我删除了这些线条,当然我检查了它。看起来像我给你的代码。
  • 您显示的代码,没有额外的空白行,仅在复制和粘贴-d 并执行时显示没有任何语法错误

标签: php syntax syntax-error notepad++


【解决方案1】:

问题出在第 181 行,其中某些内容(记事本++?!)一定发生了变化

  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

  <meta http-equiv="content-type" content="text/html; charset=Windows-1250" />

正如预期的那样,这产生了很多错误。我只是把头部部分拆下来才发现的。

【讨论】:

    猜你喜欢
    • 2017-06-11
    • 2019-08-31
    • 2015-08-17
    • 1970-01-01
    • 2016-03-01
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多