Doc #80651 [Opn->Csd]: [ZH] Example #1 chinese language

From: Date: Mon, 01 Feb 2021 08:30:09 +0000
Subject: Doc #80651 [Opn->Csd]: [ZH] Example #1 chinese language
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18476@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80651&edit=1

 ID:                 80651
 Updated by:         jhdxr@php.net
 Reported by:        super at rongsp dot com
 Summary:            [ZH] Example #1 chinese language
-Status:             Open
+Status:             Closed
 Type:               Documentation Problem
 Package:            Translation problem
 Operating System:   windows10
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=doc/zh.git;a=commit;h=abd61b44f3ed40f4f840a70a2abe2af9ef6209fe
Log: sync with en. fix #80651


Previous Comments:
------------------------------------------------------------------------
[2021-01-21 03:30:03] super at rongsp dot com

Description:
------------
---
From manual page: https://php.net/language.oop5.static
---

From https://www.php.net/manual/zh/language.oop5.static.php


<?php
class Foo
{
    public static $my_static = 'foo';

    public function staticValue() {
        return self::$my_static;
    }
}

class Bar extends Foo
{
    public function fooStatic() {
        return parent::$my_static;
    }
}


print Foo::$my_static . "\n";

$foo = new Foo();
print $foo->staticValue() . "\n";
print $foo->my_static . "\n";      // Undefined "Property" my_static 

print $foo::$my_static . "\n";
$classname = 'Foo';
print $classname::$my_static . "\n"; // As of PHP 5.3.0

print Bar::$my_static . "\n";
$bar = new Bar();
print $bar->fooStatic() . "\n";
?>
   </programlisting>
  </example>

  <example>
   <title>静态方法示例</title>
    <programlisting role="php">
<![CDATA[
<?php
class Foo {
    public static function aStaticMethod() {
        // ...
    }
}

Foo::aStaticMethod();
$classname = 'Foo';
$classname::aStaticMethod(); // 自 PHP 5.3.0 起
?>


--------------------------
   </programlisting>
  </example>

  <example>
   <title>静态方法示例</title>
    <programlisting role="php">
<![CDATA[
--------------------------

Test script:
---------------
<?php
class Foo
{
    public static $my_static = 'foo';

    public function staticValue() {
        return self::$my_static;
    }
}

class Bar extends Foo
{
    public function fooStatic() {
        return parent::$my_static;
    }
}


print Foo::$my_static . "\n";

$foo = new Foo();
print $foo->staticValue() . "\n";
print $foo->my_static . "\n";      // Undefined "Property" my_static 

print $foo::$my_static . "\n";
$classname = 'Foo';
print $classname::$my_static . "\n"; // As of PHP 5.3.0

print Bar::$my_static . "\n";
$bar = new Bar();
print $bar->fooStatic() . "\n";
?>


<?php
class Foo {
    public static function aStaticMethod() {
        // ...
    }
}

Foo::aStaticMethod();
$classname = 'Foo';
$classname::aStaticMethod(); // 自 PHP 5.3.0 起
?>




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80651&edit=1


Thread (2 messages)

« previous php.doc.bugs (#18476) next »