Ik ben maar weer eens begonnen met scripten en ik zit nu direct al met een vraag. Ik wil namelijk alles oop doen. Ik wil graag de __autoload methode gebruiken voor het laden van classes. Die functie zou ik graag in een class willen zetten, maar werkt het dan wel? Een voorbeeld van mijn code staat hieronder weergegeven.
classes/Page.class.php:
classes/Test.class.php:
index.php
classes/Page.class.php:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/class"]class[/URL] Page
[COLOR= #007700]{
function[/COLOR] __construct[COLOR= #007700]() {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]blaat[/COLOR][COLOR= #007700];
}
function[/COLOR] __autoload[COLOR= #007700]([/COLOR][COLOR= #0000BB]$class[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/include_once"]include_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]classes/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$class[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000].class.php[/COLOR][COLOR= #007700]);
}
}[/COLOR]
?> classes/Test.class.php:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/class"]class[/URL] Test
[COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/public"]public[/URL] [URL="http://www.php.net/static"]static[/URL] [COLOR= #007700]function[/COLOR] blaat[COLOR= #007700]() {[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #DD0000]blaat[/COLOR][COLOR= #007700];
}
}[/COLOR]
?> index.php
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]classes/Page.class.php[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$page[/COLOR] [COLOR= #007700]= new[/COLOR] Page[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] Test[COLOR= #007700]::[/COLOR]blaat[COLOR= #007700]();[/COLOR]
?> 
unctie