Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a simple html page with textarea and iframe first :</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function data_submit() { document.form1.txt_data.value= document.form1.txt_html.value; } &lt;/script&gt; &lt;title&gt;Try It yourself Online Editor&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="form1" id="form1" method="post" action="" &gt; &lt;table width="100%" cellspacing="0" cellpadding="0" border="1"&gt; &lt;tr &gt; &lt;td&gt; &lt;input type="submit" name="bt_submit" value="Click to Execute " align="top" onClick="data_submit();"/&gt; &lt;/td&gt; &lt;td align="center"&gt;Output&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="50%" &gt; &lt;input type="text" name="txt_data" value="" style="visibility:hidden;" /&gt; &lt;textarea rows="35" width="90px" height="550px" cols="77" name="txt_html"&gt; &lt;/textarea&gt; &lt;/td&gt; &lt;td width="50%" style="border-width:10px;border-style:none;"&gt; &lt;iframe height="550px" width="100%" src="try_it.php" name="iframe_a"&gt;&lt;/iframe&gt; &lt;/td&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now code written by the user need to be displayed in the iframe so we need to store the code in a file. Write PHP code to create a file. following is the code create a file.</p> <pre><code> if(isset($_POST['bt_submit'])) { $file = "try_it.php"; $fp = fopen($file, 'w'); //Following code will store the content in textarea in a variable which will create a file. $content = $_POST['txt_data']; fwrite($fp, $content); fclose($fp); } ?&gt; </code></pre> <p>Following php code is written to display a default output and changed output after submit button is clicked by the user.</p> <pre><code>&lt;?php if(isset($_POST['bt_submit'])) { echo trim($content); } else { echo "&lt;html&gt;\n"; echo "&lt;body&gt;\n"; echo "&lt;h1&gt;Hello World!!!&lt;/h1&gt;\n"; echo "&lt;/body&gt;\n"; echo "&lt;/html&gt;\n"; } ?&gt; </code></pre> <p>Now combine all the code and you will get a simple try it yourself editor.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload