
- You are not logged in. | Login
March 22, 2007 10:07 am
- Stre@m
- Member


By changing one variable another one is changed as well
Here is a part of the class code:
Class User {
var $authorized;
var $id;
function LoadFromSession(){
$this->$authorized = $_SESSION['authorized'];
echo "1: ".$this->$authorized."<br>";
$this->$id = 2;
echo "2: ".$this->$authorized."<br>";
}If I confer "1" on the $authorized variable first, $authorized will be changed on 2 when conferring 2 on $id variable. I.e. this part of the code will display on the screen
1:1
2:2
What could cause such problems?
March 22, 2007 10:09 am
- SRG
- Member


Re: By changing one variable another one is changed as well
Try to replace $this->$authorized with $this->authorized
March 22, 2007 10:13 am
- Stre@m
- Member


Re: By changing one variable another one is changed as well
Thanks a lot! That helped. I’ve been trying all day long but I needed only that little.
March 22, 2007 10:18 am
- biopd42
- Member


Re: By changing one variable another one is changed as well
You were just to look up manual or something…
March 22, 2007 10:21 am
- selmahyekishot
- Member


Re: By changing one variable another one is changed as well
error_reporting(E_ALL)
March 22, 2007 10:27 am
- Conker
- Member


Re: By changing one variable another one is changed as well
If you work with PHP5, I recommend you to switch on E_STRICT as well i.e. error_reporting(E_ALL|E_STRICT)
March 22, 2007 10:29 am
- Mr.SMart
- Member


Re: By changing one variable another one is changed as well
What for do you need E_STRICT?
March 22, 2007 10:32 am
- biopd42
- Member


Re: By changing one variable another one is changed as well
php.net -> man
But STRICT has nothing to do with it.


