Custom class variables in symfony
I am in trouble, I have created my own class and access functions of that class in my actionindex function using myclass::myfunction()
; but I saw a surprising behavior of class variables that when I assigned a value to one variable then all other variables are also containing that value. I want to put different value in each variable but I can't
Then I used second way of accessing class i. E .
$obj= new myclass();
$obj->myfunction();
But in that case I am unable to access public variables of class in the function, the开发者_StackOverflow中文版y are not working
in action:
public function executeFoo($request){
$obj= new myclass();
$this->output = $obj->myfunction();
}
in fooSuccess.php
<?php print_r($output); ?>
you also could output i right from the action:
public function executeFoo($request){
$obj= new myclass();
return $this->renderText($obj->myfunction());
}
精彩评论