发现编译时错误 [英] finding compile time errors

查看:93
本文介绍了发现编译时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我正在学习PHP,我在语法上犯了很多错误。


在perl中,你可以打开从浏览器中读取这些错误

加上这个:


使用CGI :: Carp''fatalsToBrowser'';


是否有类似的东西这在PHP中?


或者我是否需要找到php.ini文件并查看错误

log的位置?


我花了一些时间试图找出为什么我的类构造函数

崩溃,直到我发现我在php4设置上编写php5。什么是

大部分既定基数,是4还是5?我在php文档中看到

一些例子使用5.3,考虑到最新的稳定版本是5.2

我可以看到可能会丢失很多头发! br />

有关创建表单元素的任何建议吗?我一直用

CGI.pm来处理所有陷阱。是否有标准的php安装附带

的东西?所有我真正需要的是收音机,选择,复选框

和文字......我习惯写我需要的东西,但我也习惯不用

重新发明一个由聪明的人写的轮子!

是否使用了标准的include_path?对于包含的库,是否有任何标准的

扩展名,通常我希望它们只能通过父脚本看到

*。

Jeff

As I''m learning PHP, I''m making a fair number of mistakes in syntax.

In perl, you can turn on reading these errors from the browser by
adding this:

use CGI::Carp ''fatalsToBrowser'';

Is there something like this in PHP?

Or do I need to find the php.ini file and look to see where the error
log is?

I spent some time trying to figure out why my class constructor
crashed until I found that I was writing php5 on a php4 setup. What is
most of the established base, is it 4 or 5? I see in the php docs that
some examples use 5.3, considering that the latest stable release is 5.2
I can see how there might be a lot of hair lost!

Any recommendations on creating form elements? I''ve always used
CGI.pm which handles all the gotchas. Is there anything that comes with
the standard php install? All I really need is radio, select, checkbox
and text... I''m used to writing what I need, but I''m also used to not
reinventing a wheel that was written by someone far smarter!
Is there a standard include_path being used? Are there any standard
extensions for included libararies, generally I''d like them to be seen
*only* by the parent script.

Jeff

推荐答案

.. oO(杰夫)
..oO(Jeff)

As我正在学习PHP,我在语法上犯了很多错误。


在perl中,你可以通过
从浏览器中读取这些错误。添加这个:

使用CGI :: Carp''fatalsToBrowser'';


在PHP中有这样的东西吗?
As I''m learning PHP, I''m making a fair number of mistakes in syntax.

In perl, you can turn on reading these errors from the browser by
adding this:

use CGI::Carp ''fatalsToBrowser'';

Is there something like this in PHP?



在PHP中,默认情况下会将错误消息打印到浏览器(如果使用CLI版本,则打印到

控制台)。使用error_reporting指令

,您可以控制应显示哪些类型的错误。在开发

机器上,该指令应设置为php.ini中的E_ALL | E_STRICT。

还要确保display_errors已打开。

In PHP error messages are printed to the browser by default (or to the
console if you use the CLI version). With the error_reporting directive
you can control which types of errors should be shown. On a development
machine this directive should be set to E_ALL|E_STRICT in the php.ini.
Also make sure that display_errors is turned on.


或者我是否需要找到php.ini文件并查看错误
日志的位置?
Or do I need to find the php.ini file and look to see where the error
log is?



默认情况下没有错误日志,但你可以启用它。

By default there is no error log, but you can enable it.


我花了一些时间试图找出为什么我的类构造函数崩溃,直到我发现我在php4设置上编写php5。什么是已建立的大部分基地,是4还是5?
I spent some time trying to figure out why my class constructor
crashed until I found that I was writing php5 on a php4 setup. What is
most of the established base, is it 4 or 5?



PHP 4已经死了,最后一次支持将在几周内结束。

之后将没有更多的安全性修复已发布。因此,再次编写PHP 4脚本绝对没有意义。使用最近的5.2


PHP 4 is dead, the last support for it will finally end in a few weeks.
After that there will be no more security fixes released. So there''s
absolutely no point in writing PHP 4 scripts anymore. Use a recent 5.2
instead.


>我在php文档中看到
一些例子使用5.3,考虑到最新的稳定版本是5.2
我可以看到可能会有很多头发丢失!
>I see in the php docs that
some examples use 5.3, considering that the latest stable release is 5.2
I can see how there might be a lot of hair lost!



5.3将引入两个主要功能,即向后移植来自PHP 6,

但它还没有发布。这本手册已经包含了简短的注释,甚至包含有关即将发布的功能的完整文档,这并不罕见,因为很多人已经使用5.3甚至6进行测试。

5.3 will introduce two major features that were "backported" from PHP 6,
but it''s not released yet. It''s not unusual that the manual already
contains short notes or even full documentation about coming features,
because many people already use 5.3 or even 6 for testing.


有关创建表单元素的任何建议吗?我一直用它来处理所有陷阱的CGI.pm。
标准的php安装有什么附带的吗?我真正需要的只是收音机,选择,复选框和文字......我习惯于写我需要的东西,但我也常常不会重新发明一个由有些聪明的人!
Any recommendations on creating form elements? I''ve always used
CGI.pm which handles all the gotchas. Is there anything that comes with
the standard php install? All I really need is radio, select, checkbox
and text... I''m used to writing what I need, but I''m also used to not
reinventing a wheel that was written by someone far smarter!



有各种类和库用于创建和使用PHP维护表单。

。我不推荐一个,因为我使用自己的

代码。您可以尝试Google搜索。

There are various classes and libraries out there for creating and
maintaining forms with PHP. I can''t recommend one, since I use my own
code. You could try a Google search.


是否使用了标准的include_path?对于包含的库,是否有任何标准的扩展,通常我希望它们只能由父脚本看到。
Is there a standard include_path being used? Are there any standard
extensions for included libararies, generally I''d like them to be seen
*only* by the parent script.



不确定你的意思。


Micha

Not sure what you mean.

Micha


2008年6月13日星期五18:00:20 +0200,Jeff< jeff@spam_me_not.comwrote:
On Fri, 13 Jun 2008 18:00:20 +0200, Jeff <jeff@spam_me_not.comwrote:

因为我正在学习PHP,我''在语法上犯了相当多的错误。


在Perl中,你可以通过

来打开阅读这些错误的补充:


使用CGI :: Carp''fatalsToBrowser'';


在PHP中有这样的东西吗?
As I''m learning PHP, I''m making a fair number of mistakes in syntax.

In perl, you can turn on reading these errors from the browser by
adding this:

use CGI::Carp ''fatalsToBrowser'';

Is there something like this in PHP?



在配置中设置:

display_errors = on

error_reporting = E_ALL | E_STRICT


您也可以在运行时使用ini_set()设置这些,但语法错误将在代码运行时遇到
,所以它是'尝试通过在脚本本身设置它来捕获它们是没有用的。使用php.ini / httpd.conf /

..htaccess文件来设置该配置。


您也可以从命令行进行简单检查你有那个

可用:


php -l / / file / to / check


(其中是使用新的

(版本)编辑器时设置/创建的第一个工具之一。


Set these in the configuration:
display_errors = on
error_reporting = E_ALL | E_STRICT

You can also set these at runtime using ini_set(), but syntax errors will
be encountered _before_ the code is run, so it''s no use trying to capture
those by setting it in the script itself. Use php.ini / httpd.conf /
..htaccess files to set that configuration.

You can also do a simple check from the command line if you have that
available:

php -l /the/file/to/check

(which is one of the first tools I set/create whenever using a new
(version of) an editor).


我花了一些时间试图找出为什么我的类构造函数

崩溃,直到我发现我在php4设置上编写php5。什么是

大部分既定基数,是4还是5?
I spent some time trying to figure out why my class constructor
crashed until I found that I was writing php5 on a php4 setup. What is
most of the established base, is it 4 or 5?



PHP 4即将结束,甚至在

长之前都不会添加安全更新...

PHP 4 is end of life, not even security updates will be added before
long...


我在php文档中看到一些例子使用5.3,考虑到

最新稳定版本是5.2我可以看到可能会有很多头发

输了!
I see in the php docs that some examples use 5.3, considering that the
latest stable release is 5.2 I can see how there might be a lot of hair
lost!



是的,需要考虑的事项,没有''单独''的文件,所以

记住'' ''注释很重要:)

Yup, something to consider, there''s no ''seperate'' documentation, so
keeping in mind the ''since'' notes are important :)


有关创建表单元素的任何建议吗?我一直用

CGI.pm来处理所有陷阱。是否有标准的php安装附带

的东西?所有我真正需要的是收音机,选择,复选框

和文字......我习惯写我需要的东西,但我也习惯不用

重新发明一个由聪明的人写的轮子!
Any recommendations on creating form elements? I''ve always used
CGI.pm which handles all the gotchas. Is there anything that comes with
the standard php install? All I really need is radio, select, checkbox
and text... I''m used to writing what I need, but I''m also used to not
reinventing a wheel that was written by someone far smarter!



无法帮助你。

Couldn''t help you there.


是否使用了标准的include_path?
Is there a standard include_path being used?



是的,它被欺骗性地命名为''include_path'',并且可以设置在你的代码或配置的任何地方,保持记住目前工作的是什么
目录。

Yes, it''s deceptively named ''include_path'', and can be set anywhere in
your code or configuration, keep in mind what the current working
directory is though.


是否有任何包含图书馆的标准扩展,通常我会

喜欢它们只能*由父脚本*看到。
Are there any standard extensions for included libararies, generally I''d
like them to be seen *only* by the parent script.



只要在PHP脚本中包含库/函数/类,

它们的定义将可以从代码中的任何位置使用(不是实例

对象当然是那些服从范围)。命名空间将以PHP6到达我相信。
相信。

-

Rik Wasmus

.... spamrun完成

As soon as you include libraries/functions/classes in you PHP script,
their definitions will be usable from anywhere in the code (not instances
of objects of course, those obey scope). Namespaces will arrive in PHP6 I
believe.
--
Rik Wasmus
....spamrun finished


Michael Fesser写道:
Michael Fesser wrote:

.oO(Jeff)
.oO(Jeff)



再次感谢您的帮助。我觉得我到了某个地方。

Thanks again for your kind assistance. I feel like I''m getting somewhere.


>
>

>当我正在学习PHP时,我在语法上犯了很多错误。

在perl中,你可以通过添加以下内容从浏览器中读取这些错误:

使用CGI :: Carp''fatalsToBrowser'';

在PHP中有这样的东西吗?
> As I''m learning PHP, I''m making a fair number of mistakes in syntax.

In perl, you can turn on reading these errors from the browser by
adding this:

use CGI::Carp ''fatalsToBrowser'';

Is there something like this in PHP?



在PHP中,默认情况下会将错误消息打印到浏览器(如果使用CLI版本,则打印到

控制台)。使用error_reporting指令

,您可以控制应显示哪些类型的错误。在开发

机器上,该指令应设置为php.ini中的E_ALL | E_STRICT。

还要确保display_errors已打开。


In PHP error messages are printed to the browser by default (or to the
console if you use the CLI version). With the error_reporting directive
you can control which types of errors should be shown. On a development
machine this directive should be set to E_ALL|E_STRICT in the php.ini.
Also make sure that display_errors is turned on.



好​​的,我会找到一个检查PHP.ini文件,因为我发现脚本

默默地失败了。


OK, I''ll find a check the PHP.ini file as I''m finding that the scripts
silently fail.


>
>

>或者我是否需要找到php.ini文件并查看错误
日志的位置?
> Or do I need to find the php.ini file and look to see where the error
log is?



默认情况下,没有错误日志,但您可以启用它。


By default there is no error log, but you can enable it.


>我花了一些时间试图弄清楚为什么我的类构造函数崩溃,直到我发现我在php4设置上编写php5。什么是已建立的大部分基地,是4还是5?
> I spent some time trying to figure out why my class constructor
crashed until I found that I was writing php5 on a php4 setup. What is
most of the established base, is it 4 or 5?



PHP 4已经死了,最后一次支持将在几周内结束。

之后将不再有安全性修复已发布。因此,再次编写PHP 4脚本绝对没有意义。使用最近的5.2

代替。


PHP 4 is dead, the last support for it will finally end in a few weeks.
After that there will be no more security fixes released. So there''s
absolutely no point in writing PHP 4 scripts anymore. Use a recent 5.2
instead.



好​​的。我正在研究的那个盒子在今年被初始化了。我期待5

的东西。这必须只是我的网站主机(RackSpace)的偏好。

OK. The box I''m working on was initialized in this year. I expected 5
something. This must just be a preference with my web host (RackSpace).


>
>

>我在php文档中看到
一些例子使用5.3,考虑到最新的稳定版本是5.2
我可以看到可能会有很多头发丢失!
>I see in the php docs that
some examples use 5.3, considering that the latest stable release is 5.2
I can see how there might be a lot of hair lost!



5.3将引入两个主要功能,即反向移植来自PHP 6,

但它还没有发布。这本手册已经包含了简短的笔记,甚至是关于即将推出的功能的完整文档,这并不罕见,因为许多人已经使用5.3甚至6进行测试。


5.3 will introduce two major features that were "backported" from PHP 6,
but it''s not released yet. It''s not unusual that the manual already
contains short notes or even full documentation about coming features,
because many people already use 5.3 or even 6 for testing.



谢谢。我喜欢PHP的方向,但是有很多功能!我有点不知所措!

Thanks. I like the direction PHP seems to be going, but there are so
many "functions"! I''m a bit overwhelmed!


>
>

>关于创建表单元素的任何建议?我一直用它来处理所有陷阱的CGI.pm。
标准的php安装有什么附带的吗?我真正需要的只是收音机,选择,复选框和文字......我习惯于写我需要的东西,但我也常常不会重新发明一个由有些聪明的人!
> Any recommendations on creating form elements? I''ve always used
CGI.pm which handles all the gotchas. Is there anything that comes with
the standard php install? All I really need is radio, select, checkbox
and text... I''m used to writing what I need, but I''m also used to not
reinventing a wheel that was written by someone far smarter!



有各种类和库用于创建和使用PHP维护表单的
。我不推荐一个,因为我使用自己的

代码。您可以尝试Google搜索。


There are various classes and libraries out there for creating and
maintaining forms with PHP. I can''t recommend one, since I use my own
code. You could try a Google search.



我正在罢工,但我也想自己动手。

I''m striking out, but am thinking to roll my own also.


>
>

>是否使用了标准的include_path?对于包含的库,是否有任何标准的扩展,通常我希望它们只能由父脚本看到。
> Is there a standard include_path being used? Are there any standard
extensions for included libararies, generally I''d like them to be seen
*only* by the parent script.



不确定你的意思。


Not sure what you mean.



如果我将包含的文件命名为''my_functions.php'并将其放入网页

路径中,那不是一些这可以从网上看到。如果有人点击 http:// my_domain,我只想要什么?

的.com / my_includes.php
。也许

我什么都不担心......

PHP如何处理MySQL中的占位符?


我''我曾经这样做过:

If I name the included file ''my_functions.php'' and put it in the web
path, wouldn''t some of this be visible from the web. I just want nothing
to happen if someone hits http://my_domain.com/my_includes.php. Perhaps
I''m worrying about nothing...
How does PHP handle placeholders in MySQL?

I''m used to doing this:


这篇关于发现编译时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆