Using Notepad++, comments `//` in PHP stops the script

南笙酒味 提交于 2019-12-11 04:56:51

问题


The issue started with this question: Why does this `$_SESSION = $_POST` fail?

After some time I found that my problem described in that question is caused by the comment // in PHP (as described in the last update in the question).

I suspect my editor Notepad++ to have some kind of influence on this.

As an example, if I write:

<?
echo "test1<br>";
echo "test2<br>";
echo "test3<br>";
// Comment
echo "test4<br>";
echo "test5<br>";
?>
<?
echo "test6<br>";
echo "test7<br>";
echo "test8<br>";
?>

everything after the comment // Comment inside the current <?...?> is ignored. The output to the above is thus:

test1
test2
test3
test6
test7
test8

The other kind of comments /*...*/ works fine.

Strangely it only happens on comments that I edit or create. All other untouched comments do no harm. There might be some Notepad++ setting causing this that I don't know of. If have experienced before that "invisible" things happen when you fiddle around with the program, so I might have done something wrong at somepoint.

Any suggestions?


回答1:


Check your line endings! Save the file with unix style line endings. (Edit > EOL Conversion > UNIX format)



来源:https://stackoverflow.com/questions/11703611/using-notepad-comments-in-php-stops-the-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!