How to use a variable from another function?
问题 I want to use another variable from another function, I am tried to use the global variable, but I faild. class UploadController extends Controller { public $file;// declare my $file varable function actionIndex() { $dir = Yii::getPathOfAlias('application.uploads'); $uploaded = false; $model=new Upload(); if(isset($_POST['Upload'])) { $model->attributes=$_POST['Upload']; global $file; //use the $file varable $file=CUploadedFile::getInstance($model,'file'); //get a instance into $file varable.