doula4096 2011-12-14 13:44
浏览 58

如何从PHP文件中提取HTML?

I have a bunch of PHP files, from which I want to extract the final HTML result. For example if the PHP file content be something like:

<ul id='<% echo($newsListId) %>'>
   // PHP loop to create <li> elements
</ul>

What should be extracted is:

<ul id='news-list'>
   <li>First News</li>
   <li>Second News</li>
   <li>Third News</li>
   <li>Fourth News</li>
</ul>

What should I do? Is there a software which can do that for me?

Note: There is no dynamic content in PHP files. In other words, no connection to any external database is made in PHP files. Actually, these PHP files belong to a template I downloaded from somewhere and now I want to change their language to something else (like ASP.NET for example).

  • 写回答

3条回答 默认 最新

  • douciping4283 2011-12-14 13:46
    关注

    It would be easiest to install a local apache on your machine (Like MAMP or WAMP), and then build a PHP script that would loop over the folder structure and read each file with file_get_contents() through the server.

    If you try to read myFile.php , you will get the source, But if its parsed through the server first, meaning - reading http://localhost/myFile.php , will returned the parsed result from PHP.

    Shai.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答