简体   繁体   English

PHP-Preg_match_all-正则表达式-帮助

[英]PHP - Preg_match_all - Regular Expression - help

i've been working on this question since yesterday, i have the following code.. 从昨天开始我一直在研究这个问题,我有以下代码。

 <?php
    /* 
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    echo "evalia:".$param[1]."<br>";
    $i=0;
    while($i<100)
      $i++;
    ?>
    cvbcbcbcvb
    <?php
    echo "asdsad";
    for($i=0;$i<100;$i++)
    {
       echo $i;
    }
    ?>

and i need to get what is inside the tag.... can anyone help me? 而且我需要获取标签中的内容。...有人可以帮助我吗?

ok i explained myself really badly.... in another page i use file_get_contents to get this code ( this is only a test page nothing more) ... i can't use include for a serious reason so i need to use eval on the code inside the php tag so what i really need is the regular expression to grab everything inside the tag.. 好吧,我真的很不好意思地解释了自己...。在另一页中,我使用file_get_contents来获取此代码(仅是测试页而已)……由于严重的原因,我不能使用include,因此我需要在php标记内的代码,因此我真正需要的是正则表达式以获取标记内的所有内容。

Im my opinion you don't need to extarct the code from php tags. 我的观点是,您不需要从php标签提取代码。 You can just eval all the content of the file: 您可以评估文件的所有内容:

eval(" ?>$file_content<?php ");

You can still use include which is actually quite like eval: 您仍然可以使用include,实际上它实际上类似于eval:

include('data:text/plain;base64,'.base64_encode($file_content));

See data:// Docs for details about the data: (» RFC 2397) stream wrapper. 有关data://的详细信息,请参见data:// Docs :(»RFC 2397)流包装器。

See as well Karolis answer . 另请参阅Karolis答案

preg_match("|<\?php(.*?)\?>|msU", $string, $match);
eval($match[1]);

is it your answer? 是你的答案吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM