Class vraagje

Gestart doorAllard19 reacties26 weergaven

20 berichten · pagina 1 van 2

Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste,

Hoe kan ik dit oplossen? Regel 8 kan natuurlijk niet. Maar hoe kan het wel?

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/class"]class[/URL] BackupUser extends DomainServices
[COLOR= #007700]{[/COLOR]          
    [COLOR= #FF8000]/**
     * Standard strings, for showing the account and other functions.
     *
     */[/COLOR]    
     [COLOR= #007700]var[/COLOR] [COLOR= #0000BB]$DefaultDomain[/COLOR] [COLOR= #007700]=[/COLOR] DomainServices[COLOR= #007700]::[/COLOR]GetDefault[COLOR= #007700]();[/COLOR]

     // Rest van script[COLOR= #007700]...[/COLOR]
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Duidelijk dit...
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja vind ik ook. Er staat op regel 8 wat. Dit kan niet. Maar hoe kan ik een variabele koppelen aan een functie?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Als je een return gebruikt zou het denk ik kunnen?

(Dus in de GetDefault functie een return zetten)
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke, maar heb je een goed voorbeeld? Want mijn huidige GetDefault functie is nu dit:

[COLOR= #0000BB]<?php[/COLOR]
        [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] GetDefault[COLOR= #007700]()
        {[/COLOR]
                  [URL="http://www.php.net/global"]global[/URL] [COLOR= #0000BB]$sock[/COLOR][COLOR= #007700];[/COLOR] 
                  [COLOR= #0000BB]$sock[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]/CMD_API_ADDITIONAL_DOMAINS[/COLOR][COLOR= #007700]);[/COLOR]
                  [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$sock[/COLOR][COLOR= #007700]->[/COLOR]fetch_parsed_body[COLOR= #007700]();[/COLOR]
                        
                         [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700])
                         {[/COLOR]
                                 [URL="http://www.php.net/parse_str"]parse_str[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$info[/COLOR][COLOR= #007700]);[/COLOR]                                
                                [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]defaultdomain[/COLOR][COLOR= #007700]] ==[/COLOR]  [COLOR= #DD0000]yes[/COLOR][COLOR= #007700])
                                {[/COLOR]
                                    [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]domain[/COLOR][COLOR= #007700]];
                                }
                         }

         }[/COLOR]
?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Je hebt niet altijd een return en volgens mij stuur je meerdere returns...
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee hij stuurt er maar één. Maar het gaat om die regel 8. Hoe kan ik een variabele koppelen, aan een functie in een andere class. Oftewel, hoe kan ik een nieuwe class aanmaken, in deze class?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Bij static kan dat niet wink
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoe bedoel je? Want ik wil gewoon een bestaande class, in een class maken. Hoe?
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je moet omdat je extends gebruikt het volgende doen:

DomainServices::GetDefault() moet worden parent::GetDefault()
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ipv als var zou je hem beter als public kunnen definieren.
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja ik heb nu dit. Maar hij geeft ook een error?

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/class"]class[/URL] BackupUser extends DomainServices
[COLOR= #007700]{[/COLOR]          
    [COLOR= #FF8000]/**
     * Standard strings, for showing the account and other functions.
     *
     */[/COLOR]    
     [URL="http://www.php.net/public"]public[/URL] [COLOR= #0000BB]$DefaultDomain[/COLOR] [COLOR= #007700]=[/COLOR] parent[COLOR= #007700]::[/COLOR]GetDefault[COLOR= #007700]();     
     var[/COLOR] [COLOR= #0000BB]$userid[/COLOR][COLOR= #007700];[/COLOR]


Parse error: syntax error, unexpected (, expecting , or ; in /home/allard/domains/****/public_html/api/includes/BackupUser.php on line 8
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$parent-> dan?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Probeer eens:
self::GetDefault();
?
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Eigenlijk vind ik dat je ergens anders hulp moet gaan zoeken met je script waarmee je onze concurrent wil worden. Maar voor deze ene keer zal ik je proberen te helpen.
Je moet een __construct functie maken of een functie die aangeroepen als je die BackupUser class aanroept waarin je

$this->$DefaultDomain = parent::GetDefault();


zet
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