Usage Of Echo In Renderpartial()

I saw in Yii Blog example for renderPartial() had used this code:


<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>

why did used from echo in the beginning of code?

I know what’s third parameter of renderPartial(). when we don’t want to use boolean $return=true what’s the need to use echo?

public string renderPartial(string $view, array $data=NULL, boolean $return=false, boolean $processOutput=false)

Good morning.

I think renderPartial() translates the view code to HTML and it returns a string with this code.

Then, we need to do an echo to print it.

renderPartial()

Regards.

No You dont need to echo there. In this case it’s not needed.

But You can use it like


<?php echo $this->renderPartial('_form', array('model'=>$model),true); ?>

in this case u need echo.

function explains it better:


public function renderPartial($view,$data=null,$return=false,$processOutput=false)

{

if(($viewFile=$this->getViewFile($view))!==false)

{

$output=$this->renderFile($viewFile,$data,true);

if($processOutput)

$output=$this->processOutput($output);

if($return)

return $output;

else

echo $output;

}

else

throw new CException(Yii::t('yii','{controller} cannot find the requested view "{view}".',

array('{controller}'=>get_class($this), '{view}'=>$view)));

}

I described in first post your order, when we need go to use echo that the third parameter set to true.

My talk is, why in Yii blog example there is this mistake?