# A moving instance

- Thread: https://externals.io/message/35031
- Original archive: https://news-web.php.net/php.internals/35031
- Started by Lars Strojny on 2008-01-30T15:30:39+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #35031 — Lars Strojny — 2008-01-30T15:30:39+00:00

URL: https://externals.io/message/35031#35031

Hi,

I've recently stumbled upon the following issue: when calling a
non-static function statically from a non-static class, the instance
magically moves to the called class. It throws a strict warning, but I
wonder if this is enough. The attached example produces "Foo".

cu, Lars
-- 
  »Die Glorifizierung der prächtigen underdogs läuft auf
   die des prächtigen Systems heraus, das sie dazu macht.«
     -- Theodor W. Adorno, »Minima Moralia«: They, the people

Lars Strojny
Nießenstr. 36
51103 Cologne
Jabber/Mail: lars@strojny.net
Weblog: http://usrportage.de

---

## #35032 — Antony Dovgal — 2008-01-30T16:39:33+00:00

URL: https://externals.io/message/35031#35032 · In reply to: #35031

> Hi,
> 
> I've recently stumbled upon the following issue: when calling a
> non-static function statically from a non-static class, the instance
> magically moves to the called class. It throws a strict warning, but I
> wonder if this is enough. The attached example produces "Foo".
> 
> cu, Lars

Is this what you mean?

"$this is a reference to the calling object (usually the object to which 
the method belongs, but can be another object, if the method is called 
statically from the context of a secondary object)."

http://www.php.net/manual/en/language.oop5.basic.php

-- 
Wbr, 
Antony Dovgal
