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