1Danke
ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
204
204
EMPFEHLEN
-
31.03.08 13:40 #1
Hallo Leute,
ich habe da mal eine Frage, wieso t das nicht?
Code :1 2 3 4 5 6 7 8 9
class foo{ private $test="bla"; function getBla ($bla = $this->test) { } }
-
Nur skalare Werte können als initiale Werte vorgegeben werden. Und $this->test ist kein skalarer Wert.
Folgendes kannst du jedoch machen:PHP-Code:class foo
{
private $test="bla";
function getBla ($bla = null)
{
if( is_null($bla) ) {
$bla = $this->test;
}
}
}
Markus Wulftange
-
31.03.08 13:47 #3
Oder noch eine Alternative mit Klassenkonstanten.
PHP-Code:<?php
class foo{
const test = "bla";
function getBla ($bla = self::test)
{
echo $bla;
}
}
$foo = new foo;
$foo->getBla();
?>KIDS Kinderbetreuungsdienst
Xing
"When you play the game of thrones, you win or you die. There is no middle ground."
by Cersei Lannister in "A Game Of Thrones"
Ähnliche Themen
-
Variable Argumenten
Von MedRamBO im Forum C/C++Antworten: 4Letzter Beitrag: 29.08.10, 17:46 -
Template mit Default Parameter mit Default Initialiserung in C++
Von cockroad im Forum C/C++Antworten: 46Letzter Beitrag: 01.10.07, 10:02 -
Custom Control Properties Default Werte zuweisen?
Von the incredible Leitman im Forum C/C++Antworten: 3Letzter Beitrag: 02.08.06, 11:28 -
Default Parameter & Callback Funktionen?
Von jccTeq im Forum C/C++Antworten: 7Letzter Beitrag: 21.02.05, 11:18 -
Default-Werte aus mysql DB
Von Nob im Forum PHPAntworten: 4Letzter Beitrag: 17.12.04, 23:11





Zitieren

Login






[PHP][Snippet] Array zu XML konvertieren