purencool Posted November 25, 2010 Share Posted November 25, 2010 I have a method that is returning a funny variable, it should be returning what is below and when I echo the return from inside the method it is right. Software/Section but when I goto echo the from outside the class I get the following. It adds a back slash Software//Section this is the method code and it works fine when I echo the returnValue the value is right // Creates a dymamic case statement for making a the choice // inside and array foreach (scandir($dir) as $folderItem) { if ($folderItem != "." AND $folderItem != "..") { if (is_dir($dir.$folderItem.DIRECTORY_SEPARATOR)) { $folderItem = $folderItem ; // this allows the the dir to be placed if statements below $folderContents = $this->showPage( $dir.$folderItem ,$getPageGlobal , $subdir); $subdir = ""; // this resets so that ithe value does not get added to main links; } else { // put into if into array if($getPageGlobal== $folderItem) { $pageReturn = $dir . $folderItem; } } } } echo $pageReturn.'<br>'; return $pageReturn; This is the way I am echoing the class. This is when it decides to add the back slash echo $dynamicMenu->getShowPage(); Link to comment https://forums.phpfreaks.com/topic/219847-variable-change-from-class/ Share on other sites More sharing options...
BLaZuRE Posted November 25, 2010 Share Posted November 25, 2010 Echo out what $dir and $folderItem are. Check if $dir ends in a / and if $folderItem starts with a / and there's your problem. That's just me skimming the code, and that's what I see is probably the problem. Link to comment https://forums.phpfreaks.com/topic/219847-variable-change-from-class/#findComment-1139661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.