0

I am trying to use

    $var = "
        <?php
            if ($_SERVER['REQUEST_METHOD'] == "POST") {
                $reply = $_POST['reply'];
                $query = 'insert into reply (threadId,reply) values (' . $GLOBALS["id"] . ',' . $reply . ')';
            }
        ?>
    "

it throws out "Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)" What should I do?

  • What exactly do you want to do? Do you want to place code in a variable? please be more verbose –  Jul 27 '21 at 01:19
  • https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc – Akam Jul 27 '21 at 01:25
  • Yes I want to place the code in a variable and I want to execute the code in it later inside of the initial variable – JaneSmith30 Jul 27 '21 at 01:29
  • What you should do is rethinking the whole approach. It doesn't make sense. And certainly isn't advisable at this level of experience. – mario Jul 27 '21 at 01:35
  • How else am I supposed to write it to a file? – JaneSmith30 Jul 27 '21 at 01:37
  • https://xyproblem.info/ -- else: heredoc or nowdoc. and certainly: parameter binding. – mario Jul 27 '21 at 01:40

0 Answers0