I have a strange problem with a function i wrote. When returning an hardcoded string like "Hello" it returns this value, but when i store this value in a variable it doesn't return anything.
Also when i don't store it in a variable and try to return it nothing gets returned.
Below is my code. Can anybody see what i'm doing wrong?
Thanks in advance.
public function getPath($pageID = null) {
if($pageID == null) $pageID = $this->id;
$data = $this->_db->fetch_array("SELECT * FROM `pages` WHERE `id` = '".$pageID."'");
if(!empty($data)) {
$this->tempPath[] = $data['basename'];
if($data['parentID'] != 0) {
$this->getPath($data['parentID']);
} else {
$returnPath = $this->tempPath;
$this->tempPath = array();
$returnPath = implode('/', array_reverse($returnPath));
//This variable holds the value, when echo'ed its the correct value
echo $returnPath;
return $returnPath;
}
}
}
var_dump($returnPath);right before the return statement?