Redirect Problem


i’ve got problem using redirect at the end of a controller.

In a view, i want to use an action closed to delete, called with a link:

<?php $this->widget('zii.widgets.grid.CGridView', array(





            'template' => '{detaches}{notes}',

            'buttons' => array(

    	        'detaches' => array(




                  'url'=>'Yii::app()->createUrl("/RelStudentSemester/detache", array("id"=>$data->primaryKey,"rattrapage"=>$data->group->rattrapage_ind, "group_id"=>$data->group_id))',



This is my action code:


	 * Détache un étudiant d'un groupe

	 * @param integer $id ID du RelStudentSemester à modifier

	 * @param text $rattrapage indique si on est sur un groupe de semester ou de rattrapage

	 * @param integer $group_id indique le groupe à réafficher à la fin du traitement

	 * 	 * 	 */

	public function actionDetache($id, $rattrapage, $group_id)



		if($rattrapage == '1') // on est sur un groupe de rattrapage


			$rel->group_rattrapage = 0;



		else // groupe de semestre


			$rel->group_id = 0;



		$this->redirect(array('/groups/view', array("id"=>$group_id)));

	} // fin actionDetache

But the redirect didn’t work:

Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/GL1/protected/controllers/RelStudentSemesterController.php:6) 

I’ve check the output on line 6 of my controller, it’s just the begin of the file (it contains “<?php”).

Can someone help me?

change the code of redirect


Thanks for the reply Balu, but i’m still having the same problem with the redirect.

Make sure there’s no whitespace or other content in your controller file before the opening PHP tag.

check your files if they do not contain UTF-8 BOM header. Not every text editor will show it, but some add few bytes at the beginning of UTF8 coded files such "header"

Thanks a lot Keith and Redguy,

my problem is now solved after deleting the firsts lines of the controller.