svn: /phpdoc/zh/trunk/reference/misc/functions/ eval.xml
| From: | Dai Jie | Date: | Thu, 19 Jan 2017 15:08:42 +0000 |
| Subject: | svn: /phpdoc/zh/trunk/reference/misc/functions/ eval.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-4759@lists.php.net to get a copy of this message | ||
daijie Thu, 19 Jan 2017 15:08:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=341694
Log:
Sync with En
Changed paths:
U phpdoc/zh/trunk/reference/misc/functions/eval.xml
Modified: phpdoc/zh/trunk/reference/misc/functions/eval.xml
===================================================================
--- phpdoc/zh/trunk/reference/misc/functions/eval.xml 2017-01-19 14:44:24 UTC (rev 341693)
+++ phpdoc/zh/trunk/reference/misc/functions/eval.xml 2017-01-19 15:08:42 UTC (rev 341694)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 321375 Maintainer: daijie Status: ready -->
+<!-- EN-Revision: 338282 Maintainer: daijie Status: ready -->
<refentry xml:id="function.eval" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>eval</refname>
@@ -19,11 +19,12 @@
<caution>
<para>
- The <function>eval</function> language construct is <emphasis>very
dangerous</emphasis>
- because it allows execution of arbitrary PHP code. <emphasis>Its use thus is
- discouraged.</emphasis> If you have carefully verified that there is no other option
- than to use this construct, pay special attention <emphasis>not to pass any user
- provided data</emphasis> into it without properly validating it beforehand.
+
+ 函数<function>eval</function>语言结构是
<emphasis>非常危险</emphasis>的,
+ 因为它允许执行任意 PHP 代码。
<emphasis>它这样用是很危险的。</emphasis>
+ 如果您仔细的确认过,除了使用此结构以外
+ 别无方法, 请多加注意,<emphasis>不要允许传入任何由用户
+ 提供的、未经完整验证过的数据</emphasis> 。
</para>
</caution>
</refsect1>
@@ -39,25 +40,22 @@
需要被执行的字符串
</para>
<para>
- 代码不能包含打开/关闭 <link
- linkend="language.basic-syntax.phpmode">PHP
tags</link>。比如,<literal>'echo "Hi!";'</literal> must
be passed instead of
- <literal>'<? echo "Hi!"; >'</literal>. It is
still possible to leave and
- reenter PHP mode though using the appropriate PHP tags, e.g.
- <literal>'echo "In PHP mode!"; ?>In HTML mode!<? echo
"Back in PHP mode!";'</literal>.
+ 代码不能包含打开/关闭
+ <link linkend="language.basic-syntax.phpmode">PHP
tags</link>。比如,
+ <literal>'echo "Hi!";'</literal> 不能这样传入:
+ <literal>'<?php echo "Hi!";
?>'</literal>。但仍然可以用合适的 PHP tag 来离开、重新进入 PHP
模式。比如
+ <literal>'echo "In PHP mode!"; ?>In HTML mode!<?php echo
"Back in PHP mode!";'</literal>。
</para>
<para>
- Apart from that the passed code must be valid PHP. This includes that all statements
- must be properly terminated using a semicolon.
- <literal>'echo "Hi!"'</literal> for example will cause a
parse error, whereas
- <literal>'echo "Hi!";'</literal> will work.
+ 除此之外,传入的必须是有效的 PHP
代码。所有的语句必须以分号结尾。比如
+ <literal>'echo "Hi!"'</literal> 会导致一个 parse
error,而
+ <literal>'echo "Hi!";'</literal> 则会正常运行。
</para>
<para>
<literal>return</literal> 语句会立即中止当前字符串的执行。
</para>
<para>
- The code will be executed in the scope of the code calling
<function>eval</function>. Thus any
- variables defined or changed in the <function>eval</function> call will remain
visible after
- it terminates.
+ 代码执行的作用域是调用 <function>eval</function>
处的作用域。因此,<function>eval</function>
里任何的变量定义、修改,都会在函数结束后被保留。
</para>
</listitem>
</varlistentry>
@@ -68,8 +66,8 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- <function>eval</function> 返回 &null;,除非在执行的代码中
<literal>return</literal> 了一个值,函数返回传递给
<literal>return</literal> 的值。
- 如果在执行的代码中有一个解析错误,<function>eval</function> 返回
+ <function>eval</function> 返回 &null;,除非在执行的代码中
<literal>return</literal> 了一个值,函数返回传递给
<literal>return</literal> 的值。 PHP 7 开始,执行的代码里如果有一个
parse error,<function>eval</function> 会抛出 ParseError 异常。在 PHP 7
之前,
+ 如果在执行的代码中有 parse error,<function>eval</function> 返回
&false;,之后的代码将正常执行。无法使用
<function>set_error_handler</function> 捕获 <function>eval</function>
中的解析错误。
</para>
</refsect1>