Hallo allen,
Ik werk al een aantal jaar met php, mysql, css, html en zo nu en dan ook javascript (jquery). Echter schrijf ik nu zulke grote webbased applicaties dat ik nu toch echt over wil stappen op OOP programmeren, dus (meer) met classes en functions gaan werken.
Nou heb ik voor mezelf een klein voorbeeldje geschreven, alleen krijg ik niet de juiste output, hij zegt alleen: array...
Hij zou nu toch de array moeten echoen? Dit doet hij echter niet, krijg ook geen foutmelding.
Alvast bedankt voor jullie hulp!
Gr.
Jos
Ik werk al een aantal jaar met php, mysql, css, html en zo nu en dan ook javascript (jquery). Echter schrijf ik nu zulke grote webbased applicaties dat ik nu toch echt over wil stappen op OOP programmeren, dus (meer) met classes en functions gaan werken.
Nou heb ik voor mezelf een klein voorbeeldje geschreven, alleen krijg ik niet de juiste output, hij zegt alleen: array...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/class"]class[/URL] Eten [COLOR= #007700]{
var[/COLOR] [COLOR= #0000BB]$voorgerecht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Soep[/COLOR][COLOR= #007700];
var[/COLOR] [COLOR= #0000BB]$hoofdgerecht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Gegrilde kip[/COLOR][COLOR= #007700];
var[/COLOR] [COLOR= #0000BB]$dessert[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Dame blanche[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] Menu[COLOR= #007700]() {[/COLOR]
[COLOR= #0000BB]$array_menu[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$voorgerecht[/COLOR][COLOR= #007700])){[/COLOR]
[URL="http://www.php.net/array_push"]array_push[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array_menu[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$voorgerecht[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$hoofdgerecht[/COLOR][COLOR= #007700])){[/COLOR]
[URL="http://www.php.net/array_push"]array_push[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array_menu[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$hoofdgerecht[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dessert[/COLOR][COLOR= #007700])){[/COLOR]
[URL="http://www.php.net/array_push"]array_push[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array_menu[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$dessert[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$array_menu[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]//AFSLUITEN FUNCTIE Menu(); [/COLOR]
[COLOR= #007700]}[/COLOR]
[COLOR= #FF8000]//AFSLUITEN CLASS Eten(); [/COLOR]
[COLOR= #007700]}[/COLOR]
[COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]= new[/COLOR] Eten[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]Menu[COLOR= #007700]([/COLOR]array_menu[COLOR= #007700]);[/COLOR]
?> Hij zou nu toch de array moeten echoen? Dit doet hij echter niet, krijg ook geen foutmelding.
Alvast bedankt voor jullie hulp!

Gr.
Jos