Skip to content Skip to sidebar Skip to footer

Html Is Still Reading Php Code With

I have the following problem. I used the following code in my page to ignore some php code, but it seems that over the Thanksgiving weekend there was an update and it is no longer

Solution 1:

This is an HTML comment. It has no effect on the PHP code.

You should use PHP comments:

Block comment:

/*
BLOCK OF COMMENTED CODE
*/

Line comment:

// this is a commented line

The PHP code is interpreted by the server and is calculated "long" before it gets to the users browser. The HTML markup while still on the server, is just text. Only when the HTML arrives at the users browser does it get rendered (or ignored!). So your HTML comments did not matter to the server - it saw PHP code and ran it - the PHP interpreter is not programmed to recognize these strange <!-- symbols that you are giving it. ;)

Solution 2:

Your PHP code will always be executed because it doesn't know about your HTML code that surrounds it.

The solution, if you your PHP code not to execute is to comment it out:

<!--

<div class="main">
  <div class="main-sub">
<?// php include('http://www.contractorsintelligence.com/contractors-license/includes- // page-elements/navigation1.php'); ?>
<div id="mid-top"><img src="" width="990" height="20" alt="Top Spacer"/></div>
        <div id="mid_shdw">
-->

Solution 3:

<?php/* comments */?>

The PHP is executed before the HTML is processed client-side.

Solution 4:

If you want to ignore the PHP code, its your best bet to do it like this:

<?php/* include('http://www.contractorsintelligence.com/contractors-license/includes-page-elements/navigation1.php'); */?>

Whereas /* starts a comment and */ ends it.

PHP will parse the page before it is sent to the client (or browser). Therefore PHP is not 'interested' in <!-- or --> at all.

On the other hand, if the HTML code that is being included by your call to include() contains further HTML commentary (<!-- or -->) it may close your ignored code before the point you intended it to.

UPDATE

Your overall approach is a bit fuzzy. See here, if you want to use PHP to decide whether to show certain HTML code or not, you don't want to use HTML comments to accomplish that.

Try this instead:

<?phpif($result["r_approved"] != "APPROVED"){
?><divclass="main"><divclass="main-sub"><?phpinclude('http://www.contractorsintelligence.com/contractors-license/includes-page-elements/navigation1.php'); 
        ?></div><divid="mid-top"><imgsrc="https://www.contractorsintelligence.com/images/shadowbg-top.png"width="990"height="20"alt="Top Spacer"/></div><divid="mid_shdw"></div></div><?php
    }
?>

Solution 5:

You php page is executed and everything between <? ?> is executed. Php doesn't care about <!-- --> or any other tag except <? or <?php .

Then the browser doesn't display/load what is inside <!-- -->.

If you want to comment php, use // or /* ... */

<?php/* include('http://www.contractorsintelligence.com/contractors-license/includes-page-elements/navigation1.php'); */?>

Post a Comment for "Html Is Still Reading Php Code With "