我不知道为什么一个文件中的文本会附加到我项目中的所有.js文件中。我有一个文本文件,我从中读取,其中包含一个字符串,令我惊讶的是,它附加字符串到所有的.js文件,使他们无法加载。我该怎么做?
ken4ward . 文本只是在PHP文件中调用的。
ken4ward
session_start(); require_once('send.txt'); require_once('/Applications/MAMP/htdocs/register/DBConnect.php'); $myFile = "send.txt"; $fh = fopen($myFile, 'r'); $myFileContents = fread($fh, 21); fclose($fh); $mytrimmedvalue = trim($myFileContents);
我在控制台上遇到的错误
[Show/hide message details.] ReferenceError: ken4ward is not defined[Learn More] yui_combo.php:1:1 [Show/hide message details.] ReferenceError: ken4wardM is not defined[Learn More] javascript-static.js:1:1 SyntaxError: unexpected token: identifier[Learn More] require.min.js:1:12 [Show/hide message details.] TypeError: require is not a function[Learn More] search.php:1584:1 [Show/hide message details.] TypeError: Y is undefined[Learn More] search.php:1725:14
因为你包括
require_once('send.txt');
在页面顶部,PHP尝试将其中的文本作为变量处理。您可以简单地删除不需要的那行文本。这段代码可以帮你完成这项工作。
$myFile = "send.txt"; $fh = fopen($myFile, 'r'); $myFileContents = fread($fh, 21); fclose($fh); $mytrimmedvalue = trim($myFileContents);