Jump to content

Archived

This topic is now archived and is closed to further replies.

purencool

variable change from class

Recommended Posts

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();

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.