Classes

Gestart doorJeffreyy3 reacties44 weergaven

4 berichten · pagina 1 van 1

Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een vraagje,

Hoe kan je 2 classes in elkaar maken?
ikzelf zat te denken aan:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/class"]class[/URL] core
[COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] corefunction
    [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$text[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]bla[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$tekst[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/class"]class[/URL] leden 
    [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] ledenfunction
        [COLOR= #007700]{[/COLOR]
            [COLOR= #0000BB]$text[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]bla[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$tekst[/COLOR][COLOR= #007700];
        }
    }
}[/COLOR]
?>


Zou dat werken?
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/Class"]Class[/URL] ClassB
[COLOR= #007700]{[/COLOR]
        [COLOR= #FF8000]//Lollert[/COLOR]
[COLOR= #007700]}[/COLOR]
[URL="http://www.php.net/Class"]Class[/URL] iets
[COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/public"]public[/URL] [COLOR= #0000BB]$nieuwe_class[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] __construct[COLOR= #007700]()
        {[/COLOR]
                [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]nieuwe_class [COLOR= #007700]= new[/COLOR] ClassB[COLOR= #007700];
        }
}[/COLOR]
?>
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
maar, kan ik dan bijvoorbeeld
$ClassB->iets->functie(); gebruiken?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Bij SuperBs voorbeeld moet je dan

$class = new iets();

$class->nieuwe_class->functie();
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren