php如何检查远程服务器上是否存在文件

When I open my Linux terminal and type the following command:

rsync server_name.xxx.com:/directory_name

It works perfectly, the information of the file is shown on the screen. However, when I put the command in a php file like this:

$variable='rsync server_name.xxx.com:/directory_name'; 
$output=shell_exec($variable); 
echo $output;

Nothing shows up on the browser. Trust me, I have do the Google search for several hours, and find no clue. How can I know if a file locates at another remote server exist (readable) or not without logging on that server?

Any suggestion? Thanks a lot!

You want the file_exists function. Documentation: http://php.net/manual/en/function.file-exists.php