我的 IF 条件不工作

My IF condition isn't working

我有问题。这是我的代码:

$resultado=$ssh->exec('[ -d /usr/share/servermanager/backups/  ] && echo "found" || echo "not_found" '); 
        //die ($resultado);
            if($resultado == "found"){
                $alert_inst='<span class="label label-success mr10 mt10" >Instalado</span>';
            }else{
                $alert_inst='<span class="label label-danger mr10 mt10" >Não instalado</span>';   
            }

当我取消对 die() 的注释时,它会打印出:

found

但是 if 语句不起作用。请帮忙!

$ssh->exec 返回的字符串中 found 之前或之后可能有一些额外的空格。在比较之前对 $resultado 变量使用 trim

示例:

if(trim($resultado) == "found"){