Page 2 of 2
Re: OOP echoing out all...
Posted: Wed Feb 03, 2010 12:08 pm
by Goofan
ahh thanks that helped

.
one question if ure not occupied

how can it be that if i set $cennection instead of $this->connection i get a error but "youre" way i didnt.. i would think its beicly the same thing.
Re: OOP echoing out all...
Posted: Wed Feb 03, 2010 12:51 pm
by AbraCadaver
No, you need to read up on classes. Vars defined inside a function are destroyed when you exit the function. In a class, you set it as a class var if you need to access it later. It's the same thing with procedural programming. Check this:
Code: Select all
function foo() {
$connection = mysql_connect('localhost', 'user', 'pass');
}
foo();
if($connection) {
echo "CONNECTED";
} else {
echo "NOT CONNECTED";
}
Notice: Undefined variable: connection in code on line 7
Re: OOP echoing out all...
Posted: Wed Feb 03, 2010 3:39 pm
by Goofan
ok i think i get it abit better will look into sessions more later thanks for all though.