Hirdetés

Keresés

Új hozzászólás Aktív témák

  • Sk8erPeter

    nagyúr

    válasz Lacces #10518 üzenetére

    Ja, de most végül is mi a kérdés? :D

    Pont meg volt nyitva a NetBeans, úgyhogy bepötyögtem neked egy rövid példát a kódjaid alapján, abból hátha megérted, próbáld ki, kiírat minden szirszart:

    <?php

    class Admin {

    public $valami = 0;

    public function ez() {
    return __METHOD__;
    }
    }

    class Child extends Admin {
    public function __construct() {
    $this->valami = 1;
    }

    public function ez() {
    return __METHOD__;
    }

    public function az() {
    $parentMethodReturnValue = parent::ez();
    return 'child: "'. __METHOD__.'", parent: "'.$parentMethodReturnValue.'"';
    }

    }

    function my_var_export($var, $text = '...', $output_type = TRUE) {
    if (gettype($var) === 'string') {
    $var = htmlentities($var);
    }
    return '<p>' . $text . ($output_type ? ' (' . gettype($var) . ')' : '') . ':</p><pre>' . var_export($var, TRUE) . '</pre>';
    }

    $admin = new Admin();
    $child = new Child();

    echo my_var_export($admin, '$child');
    echo my_var_export($admin->valami, '$child->valami');
    echo my_var_export($child, '$child');
    echo my_var_export($child->valami, '$child->valami');
    echo my_var_export($child->ez(), '$child->ez()');
    echo my_var_export($child->az(), '$child->az()');

    =================

    KIMENET:

    $child (object):
    Admin::__set_state(array(
    'valami' => 0,
    ))

    $child->valami (integer):
    0

    $child (object):
    Child::__set_state(array(
    'valami' => 1,
    ))

    $child->valami (integer):
    1

    $child->ez() (string):
    'Child::ez'

    $child->az() (string):
    'child: "Child::az", parent: "Admin::ez"'

    [ Szerkesztve ]

    Sk8erPeter

Új hozzászólás Aktív témák