0

I have this code:

    <?php
    $my_var= `<script>
    </script>`;

dd($my_var);

as a result, I got that $my_var is NULL which is not. How I can solve the problem... I know I can use a single or double quote but I don't want that.

I also disable shell_exec from PHP settings...

How to solve the problem? All I need is to get the string variable...

Aleks Per
  • 1,549
  • 7
  • 33
  • 68
  • 1
    What are you trying to accomplish? To create a string with backticks in it? – Alex Howansky Dec 30 '20 at 21:01
  • Are you concerned about using single and double quotes because your full string contains both of those already? Backticks aren't a substitute for any other kind of quote, and disabling shell_exec won't change that. – iainn Dec 30 '20 at 21:03
  • yes, I have big string - HTML code with single and double quotes so I need to put that html as a string and I found that backtick is the best solution because I dont need to escape any quote ... – Aleks Per Dec 30 '20 at 21:03
  • 2
    Wherever you've found that isn't explaining things properly - backticks are a very different thing from other quotes, and not a solution for this problem. You might find [heredoc or nowdoc](https://www.php.net/manual/en/language.types.string.php) useful. – iainn Dec 30 '20 at 21:04
  • Use [Nowdoc](https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc) to avoid issues with possible interpretation of `$` in the HTML as a PHP variable. – Nick Dec 30 '20 at 22:24

0 Answers0