|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-03-08 07:18 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Hi, PHP acts strangely when calling a parent class constructor from an extended class. PHP4 seems to call the constructor without arguments instead of the one with the right number of arguments. Regards, Ari Nyk?nen // -------- clip clip clip ---------------- <script language="php"> class Huikkari { var $huikkasana="initial"; function Huikkari($huikkasana) { $this->huikkasana=$huikkasana; } function Huikkari() { $this->huikkasana="default"; } function huikkaa () { echo ($this->huikkasana."\n"); return true; } } class HelloHuikkari extends Huikkari { function helloHuikkari () { // *** possible problem here *** the following line seems // to call the Huikkari constructor with no arguments $this->Huikkari('Hello World'); } } $helloHuikkari = new HelloHuikkari(); // I think the following line should // output 'Hello World' instead of 'defaultt' $helloHuikkari->huikkaa(); </script>