php-groups.com | Post Question | Search | About | Groups | Contact | Register | Login


New in This Group

this is the test ,forget it
2/10/2009 9:05:27 AM

pass over, just the test
2/10/2009 8:59:21 AM

Top Search Engine Ranking For Targeted Keywords Guaranteed
1/28/2009 4:50:19 AM

cvs: phpdoc-zh /language oop5.xml
12/18/2008 1:19:35 AM

Suggestion: File encoding change should be a separate commit
12/17/2008 9:39:39 AM

cvs: phpdoc-zh /language exceptions.xml
12/17/2008 9:27:32 AM

cvs: phpdoc-zh /language namespaces.xml
12/17/2008 9:10:49 AM

cvs: phpdoc-zh /language expressions.xml
12/17/2008 9:07:28 AM

cvs: phpdoc-zh /language variables.xml
12/17/2008 9:00:49 AM

Two features needed for phpdoc translation ?
12/17/2008 1:41:24 AM

cvs: phpdoc-zh /language operators.xml Reply

Group: php.doc.zh Subscribe Posted:12/20/2008 11:01:01 PM Replies:0 Views:20 Items(0)
--eniac20081229814061
Content-Type: text/plain

eniac2008 Sat Dec 20 23:01:01 2008 UTC

Modified files:
/phpdoc-zh/language operators.xml
Log:
Sync with EN-Revision 1.128

--eniac20081229814061
Content-Type: text/plain
Content-Disposition: attachment; filename="eniac2008-20081220230101.txt"

http://cvs.php.net/viewvc.cgi/phpdoc-zh/language/operators.xml?r1=1.20&r2=1.21&diff_format=u
Index: phpdoc-zh/language/operators.xml
diff -u phpdoc-zh/language/operators.xml:1.20 phpdoc-zh/language/operators.xml:1.21
--- phpdoc-zh/language/operators.xml:1.20 Sat Jun 23 13:32:42 2007
+++ phpdoc-zh/language/operators.xml Sat Dec 20 23:01:01 2008
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="gb2312"?>
-<!-- $Revision: 1.20 $ -->
-<!-- $Author: bjori $ -->
-<!-- EN-Revision: 1.101 Maintainer: dallas Status: ready -->
+<!-- $Revision: 1.21 $ -->
+<!-- $Author: eniac2008 $ -->
+<!-- EN-Revision: 1.128 Maintainer: Altair Status: ready -->
+<!-- CREDITS: dallas -->
<chapter xml:id="language.operators" xmlns="http://docbook.org/ns/docbook">
<title>�����</title>
<simpara>
@@ -41,8 +42,8 @@
<tbody>
<row>
<entry>�ǽ��</entry>
- <entry>new</entry>
- <entry><link linkend="language.oop5.basic.new">new</link></entry>
+ <entry>clone new</entry>
+ <entry><link linkend="language.oop5.cloning">clone</link> �� <link linkend="language.oop5.basic.new">new</link></entry>
</row>
<row>
<entry>��</entry>
@@ -58,23 +59,37 @@
</row>
<row>
<entry>�ǽ��</entry>
- <entry>! ~ - (int) (float) (string) (array) (object) @</entry>
+ <entry>~ - (int) (float) (string) (array) (object) (bool) @</entry>
<entry>
<link linkend="language.types">����</link>
</entry>
</row>
<row>
+ <entry>�ǽ��</entry>
+ <entry>instanceof</entry>
+ <entry>
+ <link linkend="language.types">����</link>
+ </entry>
+ </row>
+ <row>
+ <entry>�ҽ��</entry>
+ <entry>!</entry>
+ <entry>
+ <link linkend="language.operators.logical">�߼�������</link>
+ </entry>
+ </row>
+ <row>
<entry>��</entry>
<entry>* / %</entry>
<entry>
- <link linkend="language.operators.arithmetic">���������</link>
+ <link linkend="language.operators.arithmetic">���������</link>
</entry>
</row>
<row>
<entry>��</entry>
<entry>+ - .</entry>
<entry>
- <link linkend="language.operators.arithmetic">���������</link>��<link
+ <link linkend="language.operators.arithmetic">���������</link>��<link
linkend="language.operators.string">�ַ��������</link></entry>
</row>
<row>
@@ -86,7 +101,7 @@
</row>
<row>
<entry>�ǽ��</entry>
- <entry>&lt; &lt;= &gt; &gt;=</entry>
+ <entry>&lt; &lt;= &gt; &gt;= &lt;&gt;</entry>
<entry>
<link linkend="language.operators.comparison">�Ƚ������</link>
</entry>
@@ -200,9 +215,9 @@
</para>
<note>
<para>
- ���� <literal>!</literal> �� <literal>=</literal> �����ȼ��ߣ�PHP
+ ���� <literal>=</literal> �����������������������ȼ��ͣ�PHP
�Ծ������������µı��ʽ��<literal>if (!$a = foo())</literal>���ڴ�����
- <literal>foo()</literal> ������������� <varname>$a</varname>��
+ <literal>foo()</literal> �ķ���ֵ�������� <varname>$a</varname>��
</para>
</note>
</sect1>
@@ -257,7 +272,10 @@
</tgroup>
</table>
<simpara>
- ���ţ���/�������Ƿ��ظ���������ʹ�����������������������ַ���ת���ɵ�������Ҳ��������
+ ������������Ƿ��ط�������ֻ��������������⣺�����������������������ַ���ת���ɵ�������������������������ʱ������һ��������
+ </simpara>
+ <simpara>
+ ȡģ������IJ�����������֮ǰ����ת������������ȥС�����֣���
</simpara>
<note>
<simpara>
@@ -269,16 +287,6 @@
�μ��ֲ��е�<link linkend="ref.math">��ѧ����</link>��
</simpara>

- <!--
- <simpara>
- The division operator ("/") returns an integer value (the ���
- of an integer division) if the two operands are integers (or
- strings that get converted to integers) and the quotient is an
- integer. If either operand is a floating-point value, or the
- operation ���s in a non-integer value, a floating-point value
- is returned.
- </simpara>
- -->
</sect1>

<sect1 xml:id="language.operators.assignment">
@@ -319,11 +327,11 @@
</informalexample>
</para>
<para>
- ע�⸳ֵ���㽫ԭ������ֵ�������±����У���ֵ��ֵ�������Ըı�����һ������Ӱ����һ������Ҳ�ʺ����ں��ܼ���ѭ���п���һЩֵ��������顣��
- PHP 4 ��֧�����ø�ֵ���� <computeroutput>$var =
- &amp;$othervar;</computeroutput> �﷨������ PHP 3
- �в����������������ø�ֵ��ζ������������ָ��ͬһ�����ݣ�û���κ����ݵĿ������й����õĸ�����Ϣ��<link
- linkend="language.references">���õ�˵��</link>��
+ ע�⸳ֵ���㽫ԭ������ֵ�������±����У���ֵ��ֵ�������Ըı�����һ������Ӱ����һ������Ҳ�ʺ����ں��ܼ���ѭ���п���һЩֵ��������顣Ҳ����ʹ�����ø�ֵ���� <computeroutput>$var =
+ &amp;$othervar;</computeroutput> �﷨�����ø�ֵ��ζ������������ָ��ͬһ�����ݣ�û���κ����ݵĿ������й����õĸ�����Ϣ��<link
+ linkend="language.references">���õ�˵��</link>����
+ PHP 5�У���������ͨ�����ø�ֵ�ģ�������ȷʹ���µ� <link
+ linkend="language.oop5.cloning">clone</link>�ؼ��֡�
</para>
</sect1>

@@ -345,6 +353,12 @@

echo "hallo" ^ "hello"; // ��� ascii ֵ #0 #4 #0 #0 #0
// 'a' ^ 'e' = #4
+
+echo 2 ^ "3"; // ��� 1
+ // 2 ^ ((int)"3") == 1
+
+echo "2" ^ 3; // ��� 1
+ // ((int)"2") ^ 3 == 1
?>
]]>
</programlisting>
@@ -477,7 +491,7 @@
<?php
var_dump(0 == "a"); // 0 == 0 -> true
var_dump("1" == "01"); // 1 == 1 -> true
-
+var_dump("1" == "1e0"); // 1 == 1 -> true
switch ("a") {
case 0:
echo "0";
@@ -623,7 +637,36 @@
�汾��Ϊ�˷���һ�����档
</simpara>
</note>
- </sect2>
+ <note>
+ <para>
+ ������⽫��Ԫ������ѻ���һ��ʹ�á�����һ�������ʹ�ö����Ԫ�����ʱ�����
+ PHP ��������������
+ Is is recommended that you avoid "stacking" ternary expressions. PHP's
+ behaviour when using more than one ternary operator within a single
+ statement is non-obvious:
+ <example>
+ <title>����������Ԫ�������Ϊ</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// է���������������� 'true'
+echo (true?'true':false?'t':'f');
+
+// Ȼ������������ʵ�������'t'����Ϊ��Ԫ������Ǵ������Ҽ����
+
+// ������������ȼ۵���䣬��������
+echo ((true ? 'true' : 'false') ? 't' : 'f');
+
+// here, you can see that the first expression is evaluated to 'true', which
+// in turn evaluates to (bool)true, thus returning the true branch of the
+// second ternary expression.
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </note>
+ </sect2>

</sect1>

@@ -636,7 +679,7 @@
<simpara>
��������� <link linkend="ini.track-errors"><option>track_errors</option></link>
���ԣ����ʽ���������κδ�����Ϣ��������ڱ���
- <link linkend="reserved.variables.phperrormsg">$php_errormsg</link>
+ <varname>$php_errormsg</varname>
�С��˱�����ÿ�γ���ʱ���ᱻ���ǣ���������������Ļ���Ҫ�����顣
</simpara>
<para>
@@ -862,6 +905,40 @@
<simpara>
���롱�͡��������ֲ�ͬ��ʽ�������ԭ����������������ȼ���ͬ����<link linkend="language.operators.precedence">��������ȼ�</link>����
</simpara>
+ <example>
+ <title>�߼������ʾ��</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// ����� foo() ���ᱻ���ã���Ϊ���DZ����������·���ˡ�
+$a = (false && foo());
+$b = (true || foo());
+$c = (false and foo());
+$d = (true or foo());
+
+// "||" �����ȼ��� "or" ��
+$e = false || true; // $e ����ֵΪ (false || true)�����Ϊ true
+$f = false or true; // $f ����ֵΪ false [Altairע��"=" �����ȼ��� "or" ��]
+var_dump($e, $f);
+
+// "&&" �����ȼ��� "and"����
+$g = true && false; // $g ����ֵΪ (true && false)�����Ϊ false
+$h = true and false; // $h ����ֵΪ true [Altairע��"=" �����ȼ��� "and" ��]
+var_dump($g, $h);
+?>
+]]>
+ </programlisting>
+ &example.outputs.similar;
+ <screen>
+<![CDATA[
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+]]>
+ </screen>
+ </example>
</sect1>

<sect1 xml:id="language.operators.string">
@@ -938,7 +1015,7 @@
</tgroup>
</table>
<para>
- <literal>+</literal> ��������ұߵ����鸽�ӵ���ߵ�������棬�����ظ��ļ�ֵ���ᱻ���ǡ�
+ <literal>+</literal> ��������ұߵ�����Ԫ�أ���ȥ��ֵ����ߵ�����Ԫ����ͬ����ЩԪ�أ����ӵ���ߵ�������棬�����ظ��ļ�ֵ���ᱻ���ǡ�
</para>
<para>
<informalexample>
@@ -1011,40 +1088,190 @@
<sect1 xml:id="language.operators.type">
<title>���������</title>
<para>
- PHP ֻ��һ�������������<literal>instanceof</literal>
- �����ⶨһ�������Ķ������ĸ������������ʵ�ֵ�<link
- linkend="language.oop5.interfaces">�ӿ�</link>�Ƿ�����ָ����<link
- linkend="language.oop">������</link>��
+ <literal>instanceof</literal> ����ȷ��һ�� PHP �����Ƿ�����ijһ��
+ <link linkend="language.oop5.basic.class">class</link> ��ʵ����
+ <example>
+ <title>instanceof ʹ��ʾ��</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class MyClass
+{
+}
+
+class NotMyClass
+{
+}
+$a = new MyClass;
+
+var_dump($a instanceof MyClass);
+var_dump($a instanceof NotMyClass);
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(true)
+bool(false)
+]]>
+ </screen>
+ </example>
</para>
- <simpara>
- <literal>instanceof</literal> ������� PHP 5 �����ġ��ڴ�֮ǰ��
- <function>is_a</function>������
- <function>is_a</function> �Ѿ���ʱ�ˣ������ <literal>instanceof</literal>��
- </simpara>
- <informalexample>
- <programlisting role="php">
+ <para>
+ <literal>instanceof</literal>��Ҳ������ȷ��һ�������Dz��Ǽ̳���ijһ����������ʵ����
+ can also be used to determine whether a variable
+ is an instantiated object of a class that inherits from a parent class:
+ <example>
+ <title>instanceof ��̳���ʾ��</title>
+ <programlisting role="php">
<![CDATA[
<?php
-class A { }
-class B { }
+class ParentClass
+{
+}
+
+class MyClass extends ParentClass
+{
+}

-$thing = new A;
+$a = new MyClass;

-if ($thing instanceof A) {
- echo 'A';
+var_dump($a instanceof MyClass);
+var_dump($a instanceof ParentClass);
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(true)
+bool(true)
+]]>
+ </screen>
+ </example>
+ </para>
+ <para>
+ ���һ������ <emphasis>����</emphasis> ij�����ʵ��������ʹ�� <link
+ linkend="language.operators.logical">�߼������ <literal>not</literal></link>��
+ <example>
+ <title>ʹ��instanceof������ <emphasis>����</emphasis> ijһ���ʵ��</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class MyClass
+{
+}
+
+$a = new MyClass;
+var_dump(!($a instanceof stdClass));
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(true)
+]]>
+ </screen>
+ </example>
+ </para>
+ <para>
+ ���<literal>instanceof</literal>Ҳ������ȷ��һ�������Dz���ʵ����ij��<link
+ linkend="language.oop5.interfaces">�ӿ�</link>�Ķ����ʵ��:
+ <example>
+ <title>Using instanceof for class</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+interface MyInterface
+{
+}
+
+class MyClass implements MyInterface
+{
+}
+
+$a = new MyClass;
+
+var_dump($a instanceof MyClass);
+var_dump($a instanceof MyInterface);
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(true)
+bool(true)
+]]>
+ </screen>
+ </example>
+ </para>
+ <para>
+ ��Ȼ <literal>instanceof</literal> ͨ��ֱ��������һ��ʹ�ã���Ҳ����ʹ�ö�����ַ���������
+ <example>
+ <title>Using instanceof with other variables</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+interface MyInterface
+{
}
-if ($thing instanceof B) {
- echo 'B';
+
+class MyClass implements MyInterface
+{
}
+
+$a = new MyClass;
+$b = new MyClass;
+$c = 'MyClass';
+$d = 'NotMyClass';
+
+var_dump($a instanceof $b); // $b is an object of class MyClass
+var_dump($a instanceof $c); // $c is a string 'MyClass'
+var_dump($a instanceof $d); // $d is a string 'NotMyClass'
?>
]]>
</programlisting>
- <simpara>
- ���� <varname>$thing</varname> ������ A ��һ�� <type>object</type>��������
- B �ģ�ֻ�к����� A ����ϵij���鱻���У�
- </simpara>
- <screen>A</screen>
- </informalexample>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(true)
+bool(true)
+bool(false)
+]]>
+ </screen>
+ </example>
+ </para>
+ <para>
+ Ȼ�� instanceof ��ʹ�û���һЩ��������˽⡣��
+ PHP 5.1.0֮ǰ�����Ҫ���������Ʋ����ڣ�<literal>instanceof</literal> ����� <link
+ linkend="language.oop5.autoload">__autoload()</link>�����⣬�������û�б�װ��������һ���������󡣿���ͨ��ʹ��<literal>��̬������(dynamic
+ class reference)</literal>����һ�������������ַ����������ܿ��������⣺
+ <example>
+ <title>���� PHP 5.0 �� instanceof ������������Һ�������������</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$d = 'NotMyClass';
+var_dump($a instanceof $d); // no fatal error here
+?>
+ ]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+bool(false)
+]]>
+ </screen>
+ </example>
+ </para>
+ <simpara>
+ <literal>instanceof</literal> ������� PHP 5 �����ġ��ڴ�֮ǰ��
+ <function>is_a</function>������
+ <function>is_a</function> �Ѿ���ʱ�ˣ������ <literal>instanceof</literal>��
+ </simpara>
<para>
�μ� <function>get_class</function> ��
<function>is_a</function>��

--eniac20081229814061--

eniac2...@php.net ("Gang Chen")
12/20/2008 11:01:01 PM





Reply:
| or Email(not shown): Name: | Register | Login

Alert me when someone responds to this posting.











Newest Articles

note 97095 added to soapclient.soapclient
4/1/2010 5:58:19 AM

note 97094 added to function.sqlite-changes
4/1/2010 5:06:46 AM

note 97093 added to function.sqlite-changes
4/1/2010 5:06:21 AM

note 97092 added to ref.xmlrpc
4/1/2010 4:52:18 AM

note 97091 added to function.var-export
4/1/2010 3:32:03 AM