使用file_put_contents将字符串放入文本文件中输出数字


Putting a string into a text file using file_put_contents outputs numbers

我想把一个php字符串放到一个文本文件中,但它只显示"0000"而不是我想要的文本。

<?php
$xml = simplexml_load_file('servers.xml');
function GetServerStatus($site, $port)
{
$status = array("OFFLINE", "ONLINE");
$fp = @fsockopen($site, $port, $errno, $errstr, 2);
if (!$fp) {
    return $status[0];
} else 
  { return $status[1];}
}
$file = 'status.txt';
file_put_contents($file, "");
foreach ($xml->server as $server){
$content = $server->location & ": " & GetServerStatus($server->ip,80);
file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
} 
?>

问题在$content行,在PHP中,连接是通过点操作符('.')完成的。

$content = $server->location . ": " . GetServerStatus($server->ip,80);