rewrite the "if" like this: echo (($method == 'api')? 'selected':'';