Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

$this variable changing unexpectedly

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

$this variable changing unexpectedly

Postby benpalmer » Tue Oct 09, 2012 2:10 pm

I have written a class with several functions. I have also stored parameters in an array called $this->function_parameters->pp_ip

The weird thing is, the values of the parameters in the array change for no reason I can see, mid way through a function which doesn't even use $this->function_parameters->pp_ip

This is the function:

Code: Select all
function spline_vary_spline_morse($input_parameters, $variation_bounds){       
             
        $fixed_a = $input_parameters->a;
        $fixed_de = $input_parameters->de;
        $fixed_re = $input_parameters->re;
               
        $varied_re = $this->vary_number($variation_bounds->re_lower, $variation_bounds->re_upper);
        $this->log_event("Loop ".$this->loop_counter." Vary morse radius from ".$fixed_re." to ".$varied_re,3);
       
        $varied_de = $this->vary_number($variation_bounds->de_lower, $variation_bounds->de_upper);
        $this->log_event("Loop ".$this->loop_counter." Vary morse depth from ".$fixed_de." to ".$varied_de,3);       
       
        $varied_a = $this->vary_number($variation_bounds->a_lower, $variation_bounds->a_upper);
        $this->log_event("Loop ".$this->loop_counter." Vary morse a from ".$fixed_a." to ".$varied_a,3);       
       
        $output_parameters = $input_parameters;
        print_r($output_parameters);
        echo "2a".chr(13).chr(10);
        print_r($this->function_parameters->pp_ip);
        echo chr(13).chr(10); 
       
        $output_parameters->a = $varied_a;
        $output_parameters->de = $varied_de;
        $output_parameters->re = $varied_re;
       
        print_r($output_parameters);
        echo "2b".chr(13).chr(10);
        print_r($this->function_parameters->pp_ip);
        echo chr(13).chr(10);       
       
        return $output_parameters;
    }


I've only put print_r in there to figure out where the values change, and it's seems to be when I assign the values to $output_parameters. The thing that gets me is that the $varied_a, $varied_de and $varied_re are the new values that appear in $this->function_parameters->pp_ip.

Are $this->function_parameters->pp_ip and $output_parameters some how linked? Am I just missing something completely about how they work in php?

Thanks
benpalmer
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Oct 09, 2012 1:59 pm

Re: $this variable changing unexpectedly

Postby seandisanti » Wed Oct 10, 2012 9:33 am

Can you post the other functions being called?
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.