How do I have a php file write inside an included file?
<p>If a php file is included/required, that has a <code>fwrite</code> function inside that included/required it, then no files will be written!</p>

<p>The only way to write would be to access the included/required file directly so an activity of writing to <code>log.txt</code> can begin.</p>

<p>Is there any way around this?</p>

<p><strong>main.php</strong></p>

<pre><code>require("inside.php")
</code></pre>

<p><strong>inside.php</strong></p>

<pre><code>//debug mode
$myFile = "test.txt"; $fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "testing shiz"."\n"); fwrite($fh, "============="."\n");
fclose($fh);     
</code></pre>

<p>When main.php is run, the file will not write. Only when inside.php is run, does it write.</p>
