...

View Full Version : How to non-display php code in browser?



gorilla1
02-13-2003, 09:44 PM
How can I comment php code so that even if php is disabled on the host, the code will not dump to the browser display... For instance, if I have the following code:
<!--
<?php

$session_start();
-->

The html commenting will prevent the code from dumping, but also screws up code execution as headers will already have been sent prior to the session start (I believe). Anyone have an idea? Thanks.
G

Spookster
02-13-2003, 10:30 PM
If php is disabled on the server then the content is going to be sent to the browser just as if it were a static html page. There's no comment you can use.

gorilla1
02-15-2003, 12:18 AM
OK, thanks. Elsewhere, someone suggested having the php in included files, so that if php is disabled, the code will never show.
Seems like that should work.
G

Spookster
02-15-2003, 12:31 AM
That's one approach I suppose although you will still be sending PHP code to the browser. And if your include files are in a web accesible folder then people would still be able to get at them.

gorilla1
02-15-2003, 03:05 PM
Thanks, Spookseter. It is not folks trying to figure out how to get at the code I am concerned about, but a situation where the code dumps out on the display - that is what seems unacceptable to me. When you say I will still be sending php code to the browser, I'm not sure if I follow. If php is disabled on the server, the include should not work, and therefore the code will not dump to the browser, I assume.
G

Spookster
02-15-2003, 04:34 PM
I'm assuming you are using PHP to include the php file? If PHP is disabled then the PHP code that is in the page that is including the file will be sent to the browser. So users will see this:

<?php
include("yourincludefile.yak");
?>

gorilla1
02-16-2003, 04:41 PM
Yes, ok. Thanks. But that is much preferable to seeing 50 or 100 lines of code.
G



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum