php 编辑器/编译器/任何显示我的代码中的错误的内容
假设我有一些代码:
<?php
echo "Hello Everybody!";
echo "<br/>" ;
$var1 = 23 ;
var_dump($var1) ;
$str = <<<HERE
some random text
more random strings
HERE;
echo $str ;
?>
现在在 localhost 上将其作为 index.php 运行,给出一个空白页面。那可能是因为代码中有一些错误。现在有什么东西(编辑器,编译器,等等)可以准确地告诉我错误在哪里以及是什么?
目前,我使用其中一个便携式服务器(XAMP、netserver、uniserver)来运行我的 php 页面,效果很好,但它没有告诉我代码中存在哪些错误。
谢谢
Lets say I have some code:
<?php
echo "Hello Everybody!";
echo "<br/>" ;
$var1 = 23 ;
var_dump($var1) ;
$str = <<<HERE
some random text
more random strings
HERE;
echo $str ;
?>
Now running this as index.php on localhost , gives a blank page. Thats probably because there is some error in the code. Now is there something(editor,compiler,whatever) that will tell me exactly where and what my error is ?
Currently I use one of those portable servers (XAMP , netserver,uniserver) to run my php pages, which works good , but it doesn't tell me what errors are there in my code.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
为此,您应该使用的工具是 PHP。
确保
error_reporting
设置为较高的值,例如E_STRICT
:The tool you should use for this is PHP.
Make sure
error_reporting
is set to something high, such asE_STRICT
:我就让其他人来回答小编的问题吧。我将回答代码中的错误部分:
有前导空格.string.syntax.heredoc" rel="nofollow noreferrer">heredoc 结束。从手册中:
I'll let others to answer the question of the editor. I'll answer the error part in the code:
to
There should be no leading space where the heredoc ends. From the manual:
检查您的 php.ini 以查看是否 error_reporting 已关闭。
Check your php.ini to see if error_reporting is turned off.
许多 IDE 都提供此功能 - 在某种程度上,我想到的是 NetBeans、Dreamweaver CS5。
他们会突出显示明显的语法错误,例如缺少分号/不平衡的括号。
但请记住,如果编译器可以识别每个错误,那么他们也可以修复它们。没有任何想法可以帮助修复不良的编程逻辑等。
同样作为下面突出显示的答案,可以关闭 error_reporting,因此应该打开以进行开发。
Many IDEs offer this functionality - NetBeans being one that comes to mind, Dreamweaver CS5 to a certain extent.
They will highlight blatant syntax errors like missing semicolons/unbalanced bracers.
But bear in mind if a compiler could identify every error then they could fix them too. no idea will help fix poor programming logic etc.
also as an answer below highlights, error_reporting can be turned off so should be turned on for development.
创建新页面,将其命名为index.php
content.php 应该是您的代码所在的页面,
现在它将显示您的错误!
另外,我几天前在 tmp 服务器上工作时注意到了一个问题。
Make new page, call it index.php
content.php should be the page where your code is,
Now it will show your error!
Also i problem i noticed couple of days ago when you're working on a tmp-server.
仅供参考,如果您只想进行快速语法检查,请对 php 二进制文件使用
-l
开关。php -l myscript.php
FYI, if you just want to do a quick syntax check, use the
-l
switch with the php binary.php -l myscript.php