Originally posted by bodzan
Hi paulnaj thanx for the response...
Unfortunatelly there are pages that serve content and perform rious calculations from MySQL database to do so... If I remove this code the page won't display anything except some pieces of code and the warning of failing to connect to the database...
This is one good reason to use functions, or rather to localise all your output functionality, rather than have it scattered across multiple files, so that the only files that can produce output when you run them directly are those that should.
So for example a file that consists entirely of
<?php
// Example only - I wouldn't do this
// with this sort of data in real life.
$database_name = 'foo';
$database_user = 'bar';
$database_password = 'wibble';
?>
doesn't produce any output, so if anyone tried requesting it directly they would, as paulnaj says, get a blank page. They would also get a blank page if the file contained something like
<?php
function footer()
{
?><div style='width:100%;font-family:sans-serif;font-size:8pt;color:lightgrey;text-align:centre;'>Copyright &amp;copy;<?php echo date('Y');?> IniTech Corporation.</div>
</body></html>
<?php
}
?>
Because there is nothing in that page that actually calls the footer() function.