I am just getting into OOP PHP but have got a little stuck.
Basically i want to create a function to create the objects, the issue is i can’t then access the objects outside of the function:
$website0 = new website(0,'test','NameTest');
echo $website0 ->getProperty('name');
This works. However:
createWebsitesFromDatabase();
echo $website0 ->getProperty('name');
function createWebsitesFromDatabase() {
$website0 = new website (0,'test','NameTest');
}
does not work. Any ideas?
1 Answer