如何将POST方法结果写入文件放内容内容?

I would like to have the the result of an HTML form POST call into the content of another PHP file. The goal is to have a redirection page generated dynamically based on the HTML form values.

$redirectionLink = $_POST["redirectionLink"];
$redirectionFileContent =
`
<?php
header("Location:.".'$redirectionLink ');
?>
`;

$otherFileLocation= 'c:\xampp\htdocs\li\something.php';
file_put_contents($otherFileLocation,$redirectionFileContent);

I receive the following output when I run the code above:

Notice: Array to string conversion in C:\xampp\htdocs\shortlink\process.php on line 25

I don't know how it would be better. Maybe store it in a variable or write into it as a post call

I'm open to suggestions.

Thank you for your help in advance.

If what you are trying to do is to simply make a new file that will redirect to the URL received from the POST request, this should do:

$longlink = $_POST["longlink"];
$redirection = <<<EOT
<?php
header('Location:{$longlink}');
?>
EOT;
file_put_contents($fileplace, $redirection);

This might solve the problem

header('Location:.$_POST["longlink"]');