Welcome Guest, Not a member yet? Register   Sign In
interesting problem about ajax,javascript,php,model =( ,please help me
#7

[eluser]CodeIgniteMe[/eluser]
[quote author="OliverHR" date="1312920955"][quote author="C_O_S" date="1312906052"]why i cant do $option.="asd"; directly?[/quote]

In fact it is an error, and no matter what it is a BAD BAD BAD practice.[/quote]

It is because the declaration of $option is at the scope that is not seen by the return $option; It's the same for all languages. I think it's called variable life-span or scope. The variable is only seen inside and beneath the container where it is declared.
Code:
Class sample{
public $var;
function some_func(){
// you can modify it here
$this->var = 'something';
// or here
for(;;):
$this->var .= 'loop';
endfor;
echo $this->var;
}
}
the same as here.
Code:
function sample2(){
$var;
for(;;):
$var .= 'loop';
endfor;
echo $var;
}
but not like this
Code:
function sample3(){
if(isset($_POST]){
$var = 'yes';
}else{
$var = 'no';
}
echo $var;
}


Messages In This Thread
interesting problem about ajax,javascript,php,model =( ,please help me - by El Forum - 08-09-2011, 07:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB