Magento 2 | Print php in template file The Next CEO of Stack OverflowMagento page.xml main content block have no template fileGet MAGE_MODE within a template file or a blockDisplay product base image in .phtml template fileInvalid template file override Magento 2 blockMagento 2 add new block template fileGet function/value from php file in .phtmlHow to override block .php file?NOINDEX,NOFOLLOW for specific template (phtml) file?not able to render phtml file magento 1.7How to create phtml file to edit home page?

MessageLevel in QGIS3

If the heap is initialized for security, then why is the stack uninitialized?

Why does the UK parliament need a vote on the political declaration?

Why didn't Khan get resurrected in the Genesis Explosion?

Which tube will fit a -(700 x 25c) wheel?

"and that skill is always a class skill for you" - does "always" have any meaning in Pathfinder?

What do "high sea" and "carry" mean in this sentence?

Is micro rebar a better way to reinforce concrete than rebar?

Why do airplanes bank sharply to the right after air-to-air refueling?

How to start emacs in "nothing" mode (`fundamental-mode`)

Is there an analogue of projective spaces for proper schemes?

If a black hole is created from light, can this black hole then move at speed of light?

multiple labels for a single equation

Inappropriate reference requests from Journal reviewers

Preparing Indesign booklet with .psd graphics for print

How do we know the LHC results are robust?

Won the lottery - how do I keep the money?

Why do professional authors make "consistency" mistakes? And how to avoid them?

What exact does MIB represent in SNMP? How is it different from OID?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Is there a way to save my career from absolute disaster?

WOW air has ceased operation, can I get my tickets refunded?

Why did we only see the N-1 starfighters in one film?

Does it take more energy to get to Venus or to Mars?



Magento 2 | Print php in template file



The Next CEO of Stack OverflowMagento page.xml main content block have no template fileGet MAGE_MODE within a template file or a blockDisplay product base image in .phtml template fileInvalid template file override Magento 2 blockMagento 2 add new block template fileGet function/value from php file in .phtmlHow to override block .php file?NOINDEX,NOFOLLOW for specific template (phtml) file?not able to render phtml file magento 1.7How to create phtml file to edit home page?










0















I got this .phtml file:



How can I make it work?
Thanks!










share|improve this question
























  • Update the pull path of file and the whole code of that file to the question

    – Sukumar Gorai
    Jul 3 '18 at 15:03











  • I have updated it.

    – k33n
    Jul 3 '18 at 15:09











  • What is the layout file?

    – Sukumar Gorai
    Jul 3 '18 at 15:09











  • I updated it again. It's all working except the code at the end.

    – k33n
    Jul 3 '18 at 15:14






  • 1





    $this->getFormUrl() instead of $block->getFormUrl()

    – Sukumar Gorai
    Jul 3 '18 at 15:15















0















I got this .phtml file:



How can I make it work?
Thanks!










share|improve this question
























  • Update the pull path of file and the whole code of that file to the question

    – Sukumar Gorai
    Jul 3 '18 at 15:03











  • I have updated it.

    – k33n
    Jul 3 '18 at 15:09











  • What is the layout file?

    – Sukumar Gorai
    Jul 3 '18 at 15:09











  • I updated it again. It's all working except the code at the end.

    – k33n
    Jul 3 '18 at 15:14






  • 1





    $this->getFormUrl() instead of $block->getFormUrl()

    – Sukumar Gorai
    Jul 3 '18 at 15:15













0












0








0








I got this .phtml file:



How can I make it work?
Thanks!










share|improve this question
















I got this .phtml file:



How can I make it work?
Thanks!







magento2 blocks phtml






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 4 mins ago







k33n

















asked Jul 3 '18 at 15:02









k33nk33n

455110




455110












  • Update the pull path of file and the whole code of that file to the question

    – Sukumar Gorai
    Jul 3 '18 at 15:03











  • I have updated it.

    – k33n
    Jul 3 '18 at 15:09











  • What is the layout file?

    – Sukumar Gorai
    Jul 3 '18 at 15:09











  • I updated it again. It's all working except the code at the end.

    – k33n
    Jul 3 '18 at 15:14






  • 1





    $this->getFormUrl() instead of $block->getFormUrl()

    – Sukumar Gorai
    Jul 3 '18 at 15:15

















  • Update the pull path of file and the whole code of that file to the question

    – Sukumar Gorai
    Jul 3 '18 at 15:03











  • I have updated it.

    – k33n
    Jul 3 '18 at 15:09











  • What is the layout file?

    – Sukumar Gorai
    Jul 3 '18 at 15:09











  • I updated it again. It's all working except the code at the end.

    – k33n
    Jul 3 '18 at 15:14






  • 1





    $this->getFormUrl() instead of $block->getFormUrl()

    – Sukumar Gorai
    Jul 3 '18 at 15:15
















Update the pull path of file and the whole code of that file to the question

– Sukumar Gorai
Jul 3 '18 at 15:03





Update the pull path of file and the whole code of that file to the question

– Sukumar Gorai
Jul 3 '18 at 15:03













I have updated it.

– k33n
Jul 3 '18 at 15:09





I have updated it.

– k33n
Jul 3 '18 at 15:09













What is the layout file?

– Sukumar Gorai
Jul 3 '18 at 15:09





What is the layout file?

– Sukumar Gorai
Jul 3 '18 at 15:09













I updated it again. It's all working except the code at the end.

– k33n
Jul 3 '18 at 15:14





I updated it again. It's all working except the code at the end.

– k33n
Jul 3 '18 at 15:14




1




1





$this->getFormUrl() instead of $block->getFormUrl()

– Sukumar Gorai
Jul 3 '18 at 15:15





$this->getFormUrl() instead of $block->getFormUrl()

– Sukumar Gorai
Jul 3 '18 at 15:15










3 Answers
3






active

oldest

votes


















1














Use the below code:



<?= $block->getFormUrl() ?>


or



<?php echo $block->getFormUrl() ?>


or



<?= $this->getFormUrl() ?>


or



<?php echo $this->getFormUrl() ?>


instead of yours



<? $block->getFormUrl() ?>


You have missed = in your php tag.






share|improve this answer
































    1














    I would not recommend php short_open_tags. Causes more issues than its worth.



    1) are short_open_tags enabled on your server?



    2) you have to use echo to print something:



    <?php echo $this->doSomething(); ?>






    share|improve this answer























    • Magento now uses the short tags btw.

      – Ben Crook
      Jul 3 '18 at 15:42











    • That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

      – tecjam
      Jul 3 '18 at 15:47












    • Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

      – Ben Crook
      Jul 3 '18 at 18:44












    • Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

      – Ben Crook
      Jul 3 '18 at 18:45











    • Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

      – tecjam
      Jul 3 '18 at 21:01


















    1














    Just put the echo



    <?php echo $block->getFormUrl() ?>





    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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%2fmagento.stackexchange.com%2fquestions%2f232208%2fmagento-2-print-php-in-template-file%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Use the below code:



      <?= $block->getFormUrl() ?>


      or



      <?php echo $block->getFormUrl() ?>


      or



      <?= $this->getFormUrl() ?>


      or



      <?php echo $this->getFormUrl() ?>


      instead of yours



      <? $block->getFormUrl() ?>


      You have missed = in your php tag.






      share|improve this answer





























        1














        Use the below code:



        <?= $block->getFormUrl() ?>


        or



        <?php echo $block->getFormUrl() ?>


        or



        <?= $this->getFormUrl() ?>


        or



        <?php echo $this->getFormUrl() ?>


        instead of yours



        <? $block->getFormUrl() ?>


        You have missed = in your php tag.






        share|improve this answer



























          1












          1








          1







          Use the below code:



          <?= $block->getFormUrl() ?>


          or



          <?php echo $block->getFormUrl() ?>


          or



          <?= $this->getFormUrl() ?>


          or



          <?php echo $this->getFormUrl() ?>


          instead of yours



          <? $block->getFormUrl() ?>


          You have missed = in your php tag.






          share|improve this answer















          Use the below code:



          <?= $block->getFormUrl() ?>


          or



          <?php echo $block->getFormUrl() ?>


          or



          <?= $this->getFormUrl() ?>


          or



          <?php echo $this->getFormUrl() ?>


          instead of yours



          <? $block->getFormUrl() ?>


          You have missed = in your php tag.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 3 '18 at 15:31

























          answered Jul 3 '18 at 15:20









          Sukumar GoraiSukumar Gorai

          6,9303729




          6,9303729























              1














              I would not recommend php short_open_tags. Causes more issues than its worth.



              1) are short_open_tags enabled on your server?



              2) you have to use echo to print something:



              <?php echo $this->doSomething(); ?>






              share|improve this answer























              • Magento now uses the short tags btw.

                – Ben Crook
                Jul 3 '18 at 15:42











              • That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

                – tecjam
                Jul 3 '18 at 15:47












              • Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:44












              • Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:45











              • Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

                – tecjam
                Jul 3 '18 at 21:01















              1














              I would not recommend php short_open_tags. Causes more issues than its worth.



              1) are short_open_tags enabled on your server?



              2) you have to use echo to print something:



              <?php echo $this->doSomething(); ?>






              share|improve this answer























              • Magento now uses the short tags btw.

                – Ben Crook
                Jul 3 '18 at 15:42











              • That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

                – tecjam
                Jul 3 '18 at 15:47












              • Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:44












              • Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:45











              • Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

                – tecjam
                Jul 3 '18 at 21:01













              1












              1








              1







              I would not recommend php short_open_tags. Causes more issues than its worth.



              1) are short_open_tags enabled on your server?



              2) you have to use echo to print something:



              <?php echo $this->doSomething(); ?>






              share|improve this answer













              I would not recommend php short_open_tags. Causes more issues than its worth.



              1) are short_open_tags enabled on your server?



              2) you have to use echo to print something:



              <?php echo $this->doSomething(); ?>







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jul 3 '18 at 15:25









              tecjamtecjam

              2,75721540




              2,75721540












              • Magento now uses the short tags btw.

                – Ben Crook
                Jul 3 '18 at 15:42











              • That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

                – tecjam
                Jul 3 '18 at 15:47












              • Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:44












              • Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:45











              • Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

                – tecjam
                Jul 3 '18 at 21:01

















              • Magento now uses the short tags btw.

                – Ben Crook
                Jul 3 '18 at 15:42











              • That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

                – tecjam
                Jul 3 '18 at 15:47












              • Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:44












              • Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

                – Ben Crook
                Jul 3 '18 at 18:45











              • Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

                – tecjam
                Jul 3 '18 at 21:01
















              Magento now uses the short tags btw.

              – Ben Crook
              Jul 3 '18 at 15:42





              Magento now uses the short tags btw.

              – Ben Crook
              Jul 3 '18 at 15:42













              That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

              – tecjam
              Jul 3 '18 at 15:47






              That is not entirely true as far as i can tell. It uses the <?= tag for echoing links or form actions, but it still uses <?php for pretty much everything else. It should also be noted that <?= is available without having to enable short_open_tags in your php.ini. Had a quick check in vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml

              – tecjam
              Jul 3 '18 at 15:47














              Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

              – Ben Crook
              Jul 3 '18 at 18:44






              Isn't <?= the equivalent of <?php echo? . And just check out any template you'll see they have replaced <?php echo with <?=. First template I went to - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/… The template you mention also uses shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

              – Ben Crook
              Jul 3 '18 at 18:44














              Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

              – Ben Crook
              Jul 3 '18 at 18:45





              Even pages completely unrelated to forms are using the shorthand - github.com/magento/magento2/blob/2.2-develop/app/code/Magento/…

              – Ben Crook
              Jul 3 '18 at 18:45













              Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

              – tecjam
              Jul 3 '18 at 21:01





              Exactly as I said. It is not, however, using short open tags which requires php.ini settings.

              – tecjam
              Jul 3 '18 at 21:01











              1














              Just put the echo



              <?php echo $block->getFormUrl() ?>





              share|improve this answer



























                1














                Just put the echo



                <?php echo $block->getFormUrl() ?>





                share|improve this answer

























                  1












                  1








                  1







                  Just put the echo



                  <?php echo $block->getFormUrl() ?>





                  share|improve this answer













                  Just put the echo



                  <?php echo $block->getFormUrl() ?>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 3 '18 at 17:12









                  RaviRavi

                  190113




                  190113



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • 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%2fmagento.stackexchange.com%2fquestions%2f232208%2fmagento-2-print-php-in-template-file%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







                      Popular posts from this blog

                      Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

                      Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр

                      Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»