PHP将数据发送/保存到txt文件

PHP将数据发送/保存到txt文件,php,Php,我正在开发一个电报机器人,它使用PHP向客户端发送数据。 这是一个电报机器人,允许用户检查域名是否已经注册。如果未注册,则允许用户注册,如果已注册,则返回注册域名的whois信息 这是我代码的一部分: if($inText) { $domain = trim($inText); if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7); if(substr(strtol

我正在开发一个电报机器人,它使用PHP向客户端发送数据。 这是一个电报机器人,允许用户检查域名是否已经注册。如果未注册,则允许用户注册,如果已注册,则返回注册域名的whois信息

这是我代码的一部分:

 if($inText) {
    $domain = trim($inText);
    if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7);
    if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);
        if(ValidateIP($domain)) {
        $caption = LookupIP($domain);
    }
    elseif(ValidateDomain($domain)) {
        $caption = LookupDomain($domain);
        //$errorchars = array('no match','No results','NOT FOUND');
        //strtolower($errorchars)
        if(strpos(strtolower($caption),'no match') !== false or strpos(strtolower($caption),'no results') !== false or strpos(strtolower($caption),'not found') !== false){
            $caption = "
            You can use file_put_contents function to save data into the file with only one command.

Example:

file_put_contents("yourfilenametosavedata.txt", $caption);
if($inText){
$domain=trim($inText);
如果(substr(strtolower($domain),0,7)=“http://”$domain=substr($domain,7);
如果(substr(strtolower($domain),0,4)=“www.”$domain=substr($domain,4);
if(验证EIP($domain)){
$caption=LookupIP($domain);
}
elseif(ValidateDomain($domain)){
$caption=LookupDomain($domain);
//$errorchars=array('no match'、'no results'、'NOT FOUND');
//strtolower($errorchars)
if(stropos(strtolower($caption),'no match')!==false或stropos(strtolower($caption),'no results')!==false或stropos(strtolower($caption),'not found')!==false){
$caption=”
只需一个命令,即可使用函数将数据保存到文件中

例如:


就是这样。

file\u put\u contents()
?所以我只在$caption后面添加这一行?如何将它们结合起来?我不是PHP专家。我不知道如何将这段代码与我的代码结合起来。@ArtaS,是的。例如在“$sendP1=sendMessage($cid,$caption,$botapi,$encodedMarkup)”行之后添加行:file\u put\u contents($domain..txt,$caption);这将把文件“entereddomainname.txt”保存在php文件所在的同一文件夹中。或者使用以下行:file\u put\u contents($cid.'.$domain..txt“,$caption);然后您将得到名为“clientid\u entereddomainname.txt”的文件。谢谢。干杯