I ve built this simple online tool to convert html, css or javascript into php compatible coding string. Not much tricky but just another link for portfolio. Suggessions required from seniors plz.

Location: http://www.movetophp.com

    It does not recognise multiple lines, it writes the lot as one.

    Also is echo the only thing it does??

      oh, found a bug. It doesn't cancel out dollar signs.

      for example, if you do the following;

      <html>
      <script>
      
      function $(id){
      return document.getElementById(id);
      }
      
      </script>
      </html>

      The Simple way to fix this problem would be to be surround the full thing with single quotes rather than double quotes.

        dougal85 wrote:

        Am i not right in thinking it only needs to cancel double quotes?

        Heredoc syntax would also require dollar signs to be escaped.

        If I was going to echo a big chunk of arbitrary text it would be as

        ?>
        <html>
        <script>
        
        function $(id){
        return document.getElementById(id);
        }
        
        </script>
        </html>
        <?php
        

        If I needed to capture that to a variable

        ob_start();
        ?>
        <html>
        <script>
        
        function $(id){
        return document.getElementById(id);
        }
        
        </script>
        </html>
        <?php
        $variable = ob_get_clean();

        Although in both cases I'd need to properly escape "<?php" if it appears.

          Write a Reply...