I'm creating various 'my version' of web services. Basically, it's a yii controller with lots of actions.. each action is as follow
public function actionNameOfWebService()
{
if(isset($_POST))
{
// do some processing, when I have a result... I do ..
print CJSON::encode('result.');
}
else
{
print CJSON::encode('only post methods allowed');
}
}
Lots of those actions are in one particular controller. Everything's working fine..before I go to production, do I need to add a 'die;' statement after every print CJSON::encode statement.
You don't have to but when you add it, you'll be sure that nothing will be printed after JSON, which will break parsers attempts to read that data.
But if you know that there is nothing more, you can skip it.