Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript PHP和JS帮助:函数不';不接受用echo粘贴的参数_Javascript_Php - Fatal编程技术网

Javascript PHP和JS帮助:函数不';不接受用echo粘贴的参数

Javascript PHP和JS帮助:函数不';不接受用echo粘贴的参数,javascript,php,Javascript,Php,下面是我用来通过PHP粘贴HTML的长代码行: echo "<h2 style=\"color: white!important; background: black!important; border: 4px black solid!important;\">", $p_name, "<span id=\"portfolio-", $p_id, "\" onclick=\"expandToggle(this);\" style=\"float: right; padding

下面是我用来通过PHP粘贴HTML的长代码行:

echo "<h2 style=\"color: white!important; background: black!important; border: 4px black solid!important;\">", $p_name, "<span id=\"portfolio-", $p_id, "\" onclick=\"expandToggle(this);\" style=\"float: right; padding-right: 10px; cursor: pointer;\">+</span>", "<span onmouseover=\"getNotify(this, true)\" onmouseout=\"getNotify(this, false)\" onclick=\"window.open(",$p_get,")\" style=\"float: right; cursor: pointer; padding-right: 15px;\">⬇</span></h2>";

如何修复此问题?

url周围似乎有新行(
\n
)字符

echo "<h2 style=\"color: white!important; background: black!important; border: 4px black solid!important;\">",
 $p_name, "<span id=\"portfolio-", $p_id, "\" onclick=\"expandToggle(this);\" style=\"float: right; padding-right: 10px; cursor: pointer;\">+</span>",
 "<span onmouseover=\"getNotify(this, true)\" onmouseout=\"getNotify(this, false)\" onclick=\"window.open('",str_ireplace("\n", "", $p_get),"')\" style=\"float: right; cursor: pointer; padding-right: 15px;\">⬇</span></h2>";
更新:
由于您的代码可能很难阅读,因此很难理解,这里是一个更好的格式化解决方案

printf(
    '<h2 style="color: white!important; background: black!important; border: 4px black solid!important;">
        %s
        <span id="portfolio-%d" onclick="expandToggle(this);" style="float: right; padding-right: 10px; cursor: pointer;">+</span>
        <span onmouseover="getNotify(this, true)" onmouseout="getNotify(this, false)" onclick="window.open(\'%s\')" style="float: right; cursor: pointer; padding-right: 15px;">⬇</span>
    </h2>',
     $p_name, $p_id, str_replace("\n", "", $p_get)
);
printf(
'
%
+
⬇
',
$p_name、$p_id、str_replace(“\n”、“”、$p_get)
);

哦,我这边有个错误。我使用一个文本文件从中获取信息,然后循环一个数组并粘贴到网站上。我使用explode()php函数来划分项目部分及其描述,其中有nl。是的。谢谢使用
PHP\u EOL
而不是“\n”@LexLaiden Cheers。URL不也应该用引号括起来吗?据我所知,不是。那不可能是对的。@Davor是的。检查内部html部分。
window.open('",str_ireplace("\n", "", $p_get),"')
printf(
    '<h2 style="color: white!important; background: black!important; border: 4px black solid!important;">
        %s
        <span id="portfolio-%d" onclick="expandToggle(this);" style="float: right; padding-right: 10px; cursor: pointer;">+</span>
        <span onmouseover="getNotify(this, true)" onmouseout="getNotify(this, false)" onclick="window.open(\'%s\')" style="float: right; cursor: pointer; padding-right: 15px;">⬇</span>
    </h2>',
     $p_name, $p_id, str_replace("\n", "", $p_get)
);