2014-08-24 11:22
浏览 72

在Sublime Text 3中需要正确的PHP输出

How to correctly print the result of the php code in Sublime Text 3? My code is:


   $nums = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');

   echo "<table><tr>";

   foreach($nums as $i) {

     foreach($nums as $j)
         echo "<td>".($i*$j)."</td>";   

      if ($i != 10) echo "</tr><tr>";


  echo "</tr></table>";

Output: output Hope that it can be possible to get the result in console like this (from here) expected result Maybe I should use another syntax instead of <tr></tr> <td></td> <table></table>? Thanks for watching!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongpa9277
    dongpa9277 2014-08-24 11:45

    In Sublime you can only see the output of a PHP script as text.

    To render the output like you showed in the example you will need to use a browser.

    To do this you will need a local http server.

    Use XAMPP. (works on both Windows and Linux)

    Steps to make it work:

    • install xampp
    • move your project into xampp_install_location/htdocs/your_project/
    • start the xampp server either by using the interface on windows or from the cli in linux
    • open a browser and go to http://localhost/your_project/filename.php
    点赞 评论