Excuse me, this recursion prints the return value before the return value, there is an output, but the return value is null.

function saveWeixinFile($filename, $filecontent)
{
    if(!file_exists($filename))
    {
        $local_file = fopen($filename, "w");
        if(false !== $local_file)
        {
            if(false !== fwrite($local_file, $filecontent))
            {
                
                fclose($local_file);
                var_dump($filename);
                return $filename;
            }
        }
    }else{
        $filenameex = explode(".",$filename);
        $bracketsleft = strrpos($filenameex[0],"(");
        if($bracketsleft)
        {
            $countleng = strlen($filenameex[0]);
            $num = substr($filenameex[0],$bracketsleft+1,$countleng-$bracketsleft-2);
            $numadd = $num+1;
            $filename = str_replace("(".$num.")","(".$numadd.")",$filename);
        }else{
            $num = 1;
            $filename = $filenameex[0]."(".$num.").".$filenameex[1];
        }
        saveWeixinFile($filename, $filecontent);
    }
}
var_dump(saveWeixinFile("text.txt","aa"));

this code has a return value the first time it is run, but there is no return value since the second run. Every time it is var_dump before return ($filename); it is printed. What is the reason for returning null? Is the number of runs, not the number of code recursions

Php
Apr.24,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f66c-2b1d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f66c-2b1d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?