php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19980 Static method call from non-statiic method fails.
Submitted: 2002-10-18 10:07 UTC Modified: 2003-01-02 18:37 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: xczimi at sztaki dot hu Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.2.3 OS: Win2000
Private report: No CVE-ID: None
 [2002-10-18 10:07 UTC] xczimi at sztaki dot hu
when calling B::procSave from $a->procSave() the $this keeps linked to $a.

The code:
<?php

class A {
  function A() {}
  function procSave() {
    echo "A";
    if(isset($this)) echo "y"; else echo "n";
    B::procSave();
  }
}

class B {
  function B() {}
  function procSave() {
    echo "B";
    if(isset($this)) echo "y"; else echo "n";
  }
}

$a = new A();
$b = new B();

$a->procSave();
B::procSave();

?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-18 10:26 UTC] tal@php.net
And the output is?
 [2002-10-18 10:31 UTC] xczimi at sztaki dot hu
AyByBn
 [2002-10-18 15:43 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php
 [2002-10-18 19:46 UTC] mfischer@php.net
This came up on ZE2 list also, people seem to have a need for this. Please participate there.
 [2002-10-21 03:34 UTC] xczimi at sztaki dot hu
The example on the manual is correct, but here, the class A and the class B do not extend each other (they donot know anything about each other logically), so I do not think in a function of B the $this may be an object of class A.

Where can I find ZE2 list?
 [2002-10-21 11:41 UTC] sniper@php.net
Reclassified. I guess ZE2 will solve this?

 [2002-12-08 17:12 UTC] iliaa@php.net
Please try the latest ZE2 cvs and see if the problem still exists.
 [2003-01-02 18:37 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 10:01:27 2024 UTC