# Conditional class definition in PHP 4.3.x

- Thread: https://externals.io/message/6792
- Original archive: https://news-web.php.net/php.internals/6792
- Started by Marcus Boerger on 2004-01-05T14:37:53+00:00
- Messages: 5
- 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

---

## #6792 — Marcus Boerger — 2004-01-05T14:37:53+00:00

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

Hello internals,

version 5 does neither support nested classes nor conditional classes.
Not supporting the former is a bit of a loss but the latter leads to
ugly software design so no worry here.

Anyway i tried the test script with 4.3.5-dev and there conditional
classes are present but not working. Hence i suggest we disable or fix
them.

Further more i think we cannot fix it becasue the script mixes compile
time and run time. It tries something like selfmodifying code.


Since i think it is ugly software design anyways i am pro disabling.

marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'
0
marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'
0

-- 
Best regards,
 Marcus                          mailto:helly@php.net

---

## #6793 — Christian Schneider — 2004-01-05T14:58:22+00:00

URL: https://externals.io/message/6792#6793 · In reply to: #6792

Marcus Boerger wrote:
> Further more i think we cannot fix it becasue the script mixes compile
> time and run time. It tries something like selfmodifying code.

I agree that it should be disabled. If someone really, really wants to 
do it they can still include/eval conditionally.

- Chris

---

## #6794 — Marcus Boerger — 2004-01-05T15:09:39+00:00

URL: https://externals.io/message/6792#6794 · In reply to: #6793

Hello Christian,

Monday, January 5, 2004, 3:58:22 PM, you wrote:

> Marcus Boerger wrote:
> > […]

> I agree that it should be disabled. If someone really, really wants to 
> do it they can still include/eval conditionally.

And in php 5 one can use the __autoload() feature which is the correct
choice for such designs where classes are optional.

-- 
Best regards,
 Marcus                            mailto:helly@php.net

---

## #6796 — Andi Gutmans — 2004-01-05T16:22:04+00:00

URL: https://externals.io/message/6792#6796 · In reply to: #6792

This is strange. I remember it used to work. We'll look into it.

Andi

At 03:37 PM 1/5/2004 +0100, Marcus Boerger wrote:
>Hello internals,
>
>version 5 does neither support nested classes nor conditional classes.
>Not supporting the former is a bit of a loss but the latter leads to
>ugly software design so no worry here.
>
>Anyway i tried the test script with 4.3.5-dev and there conditional
>classes are present but not working. Hence i suggest we disable or fix
>them.
>
>Further more i think we cannot fix it becasue the script mixes compile
>time and run time. It tries something like selfmodifying code.
>
>
>Since i think it is ugly software design anyways i am pro disabling.
>
>marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function 
>f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'
>0
>marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function 
>f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'
>0
>
>--
>Best regards,
>  Marcus                          mailto:helly@php.net

---

## #6981 — Andi Gutmans — 2004-01-11T19:38:58+00:00

URL: https://externals.io/message/6792#6981 · In reply to: #6792

I fixed this problem. I agree it's not great coding but there's no real 
reason to break BC on this issue.
I also fixed the problem with conditional function declerations being on 
the same line.

Andi

At 03:37 PM 1/5/2004 +0100, Marcus Boerger wrote:
>Hello internals,
>
>version 5 does neither support nested classes nor conditional classes.
>Not supporting the former is a bit of a loss but the latter leads to
>ugly software design so no worry here.
>
>Anyway i tried the test script with 4.3.5-dev and there conditional
>classes are present but not working. Hence i suggest we disable or fix
>them.
>
>Further more i think we cannot fix it becasue the script mixes compile
>time and run time. It tries something like selfmodifying code.
>
>
>Since i think it is ugly software design anyways i am pro disabling.
>
>marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (1) {class a{function 
>f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'
>0
>marcus@zaphod /usr/src/PHP_4_3_0 $ php -r 'if (0) {class a{function 
>f(){return 1;}}}else{class a{function f(){return 0;}}}echo a::f()."\n";'
>0
>
>--
>Best regards,
>  Marcus                          mailto:helly@php.net
