HTML Generator: Convert HTML to PlainText and put

2019-08-13 13:04发布

问题:

I would like to make a generator to get easy work in eBay description. So i've created a page with some form input that send the value to a php page in the main page iframe. Now I need to take the full HTML code and put in the iframe (naturally I get the full rendered page) and I need to view the source code, copy and put in the eBay html description.

So, the question is: Can I convert the HTML code as plain text and put in a textbox so I can easily copy using a button? I don't need a wysiwycg.

I've googled it but can't find a reasonable result.

According to your reply, here is the code now:

Page1.php

// It's only the page containing the form that must to pass variables

Page2.php

$html = file_get_contents('desc.php');

echo '<textarea readonly style="border:none;resize:none" rows="50" cols="116" value="'. $html .'"></textarea>';

Page3.php

// This is the file desc.php that must to be in plaintext

Now I get the plain text file but the variables aren't passed since i've stored them in session.

And the textbox displays only half of the file, not showing the <link> and <style> tags.

回答1:

You can use file_get_contents

$homepage = file_get_contents('http://www.example.com/');


echo $homepage;

or

 echo "<td><input type='text' value='$homepage'/></td>";

or for i frame

<iframe> 
   <div inside frame>
      <$php echo $content; ?>
   </div>
</iframe>


标签: php html iframe