Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to non-display php code in browser?

    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

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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");
    ?>
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, ok. Thanks. But that is much preferable to seeing 50 or 100 lines of code.
    G


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •