将textarea内部/值转换为PHP字符串需要一些帮助

My code should combine PHP / HTML / JS.

What I want to do is copy the text from the myurl textarea, while writing.

And save it as new $myurl PHP

PHP/HTML:

<?php
$myurl = $_SERVER['REQUEST_URI'];
// That the new $myurl would be here before the php code closed
?>

<html>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <body>
    <center>
        <textarea id="myurl" class="form-control" style="color:black; background-color:#fff; resize:none;">  txt i want to save as $myurl string </textarea>
        <br>
        <div>
            <span style="color:#fff" class="" id="test">test</span>
            </span>
            <input id="submit" name="submit" type="submit" class="btn btn-primary" onclick="test3();" value="Submit" disabled/>
        </div>
    </center>
    <center><div class="test2"></div><br></center>
    // The js file is not related to the subject:
    <script src='index.js'></script>
</body>
</html>

UPDATE (What I tried):

<script>
    $(document).ready(function(){
        $('#myurl').on('change keyup paste',function(){
            $("#submit").click()
        });
    });
</script>

<script>
    function test3(){
        var javavar=document.getElementById("myurl").value;
        document.getElementById("myurl").innerHTML="<?php $myurl='"+javavar+"'; echo $myurl;?>";}
</script>

This should be saved as a PHP string. But I add at the beginning of the page echo $myurl It shows nothing.

I do not want echo to be inside the script

Try this, but I'm not sure that I understood correctly what you want

form.php

<?php
    $myurl = filter_input(INPUT_POST, 'myurl');
    $form = <<<FORM
<!DOCTYPE html>
<html>
<head>
    <link rel="icon" href="data:;base64,iVBORw0KGgo=">
</head>
<body>
     <form action="form.php" method="POST">
         <textarea name="myurl">txt i want to save as string </textarea>
         <input type="submit" value="Submit"/>
     </form>
     <p>Result: {$myurl}</p>
</body>
</html>
FORM;

    header('Content-Type: text/html; charset=utf-8');
    echo $form;

hope it help