I have an index.php and a Regions.php which is a class. I'm trying to call a method from Regions class to my index.php but it seems I can't access it.It says:
Call to undefined function getRegionInfo() in C:\xampp\htdocs\exercise4\index.php on line 7
But I already included the files I need. Here's the code.
index.php
$regions = new Regions;
$regions = getRegionInfo();
$regions = get_regions();
Here's my Region class
class Regions
{
public function getRegionInfo()
{
$this->get_regions();
}
private function get_regions()
{
global $db;
$result = array();
$sql = "SELECT RegionID, RegionName, IslandID FROM ref_regions";
$stmt = $db->prepare($sql);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $stmt->fetch())
{
array_push($result,array($row['RegionID'], $row['RegionName'], $row['IslandID']));
}
return $result;
}
}