In PHP: are single quotes safer than double quotes?












-1















I am working on a textarea block on a PHTML page in Magento 2.



In order to generate line breaks using r and rn in the predefined content of the block, I need double quotes instead of single quotes.



Considered that PHP interpretes variables in a string with double quotes:
Is there any possible safety issue when using double quotes instead of single quotes in a textarea in PHP?



If there is a risk: what is the best/easiest way to sanitize the user input in the textblock when making use of double quotes?










share|improve this question





























    -1















    I am working on a textarea block on a PHTML page in Magento 2.



    In order to generate line breaks using r and rn in the predefined content of the block, I need double quotes instead of single quotes.



    Considered that PHP interpretes variables in a string with double quotes:
    Is there any possible safety issue when using double quotes instead of single quotes in a textarea in PHP?



    If there is a risk: what is the best/easiest way to sanitize the user input in the textblock when making use of double quotes?










    share|improve this question



























      -1












      -1








      -1








      I am working on a textarea block on a PHTML page in Magento 2.



      In order to generate line breaks using r and rn in the predefined content of the block, I need double quotes instead of single quotes.



      Considered that PHP interpretes variables in a string with double quotes:
      Is there any possible safety issue when using double quotes instead of single quotes in a textarea in PHP?



      If there is a risk: what is the best/easiest way to sanitize the user input in the textblock when making use of double quotes?










      share|improve this question
















      I am working on a textarea block on a PHTML page in Magento 2.



      In order to generate line breaks using r and rn in the predefined content of the block, I need double quotes instead of single quotes.



      Considered that PHP interpretes variables in a string with double quotes:
      Is there any possible safety issue when using double quotes instead of single quotes in a textarea in PHP?



      If there is a risk: what is the best/easiest way to sanitize the user input in the textblock when making use of double quotes?







      php security reference magento2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 11:48







      Els den Iep

















      asked Nov 19 '18 at 11:30









      Els den IepEls den Iep

      190111




      190111
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Unless you are dynamically generating PHP from user input and then evaluating it, there is no risk from user input just because you use a double-quoted string literal.






          share|improve this answer
























          • Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

            – Els den Iep
            Nov 19 '18 at 11:36











          • I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

            – Els den Iep
            Nov 19 '18 at 11:45













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373711%2fin-php-are-single-quotes-safer-than-double-quotes%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Unless you are dynamically generating PHP from user input and then evaluating it, there is no risk from user input just because you use a double-quoted string literal.






          share|improve this answer
























          • Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

            – Els den Iep
            Nov 19 '18 at 11:36











          • I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

            – Els den Iep
            Nov 19 '18 at 11:45


















          0














          Unless you are dynamically generating PHP from user input and then evaluating it, there is no risk from user input just because you use a double-quoted string literal.






          share|improve this answer
























          • Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

            – Els den Iep
            Nov 19 '18 at 11:36











          • I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

            – Els den Iep
            Nov 19 '18 at 11:45
















          0












          0








          0







          Unless you are dynamically generating PHP from user input and then evaluating it, there is no risk from user input just because you use a double-quoted string literal.






          share|improve this answer













          Unless you are dynamically generating PHP from user input and then evaluating it, there is no risk from user input just because you use a double-quoted string literal.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 11:34









          QuentinQuentin

          647k718761041




          647k718761041













          • Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

            – Els den Iep
            Nov 19 '18 at 11:36











          • I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

            – Els den Iep
            Nov 19 '18 at 11:45





















          • Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

            – Els den Iep
            Nov 19 '18 at 11:36











          • I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

            – Els den Iep
            Nov 19 '18 at 11:45



















          Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

          – Els den Iep
          Nov 19 '18 at 11:36





          Thanks. I am using the textarea in a custom contact form in Magento 2. Would you consider that dynamically generating PHP from user input and then evaluating it?

          – Els den Iep
          Nov 19 '18 at 11:36













          I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

          – Els den Iep
          Nov 19 '18 at 11:45







          I agree that I should not have used the term "consider" as it refers to an opinion. Still, I am not sure about the user input risk using double quotes. That is why I am seeking advice from somebody who knows..

          – Els den Iep
          Nov 19 '18 at 11:45






















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373711%2fin-php-are-single-quotes-safer-than-double-quotes%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()