PHP切换功能不显示真实结果

时间:2015-08-02 09:53:04

标签: php switch-statement

我有这个函数用于显示类型名称:

function is_typename($type){

    switch ($type){
    case 1:
        echo "Bring an extra $500";
        break;
    case 2:
        echo "Bring an open mind";
        break;  
    case 3:
        echo "Bring 15 bottles of SPF 50 Sunscreen";
        break;  
    case 4:
        echo "Bring lots of money";
        break;
    case 5:
        echo "Bring a swimsuit";
        break;  
    }

}

没有显示链接我有:

echo '<a href="'.SITE.''.$lang.'/'.is_typename($type).'/'.$id.'/'.$seotitle.'" rel="nofollow" title="'.$title.'" target="'.$target.'">'.$title.'</a>';  

在行动中我看到:

Bring an extra $500<a href="http://localhost/cms/en//241/titeltest" rel="nofollow" title="titeltest" target="_blank">titeltest</a>

问题:$type和typename显示在外部href<a></a>中。怎么解决这个问题?

1 个答案:

答案 0 :(得分:2)

而不是echo use return,

示例

case 1:
        return "Bring an extra $500";
        break;