[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2094
  • Last Modified:

Exclude some code in a .php file

Hello all.

I cant figure out how to exclude some code in my .php file. Its php code.

When using html i just use <!-- --> but now i cant figure out the same rhytme with php :S

Seems so easy, but i cant bing it.


HELP ME, I KEEP BEING A NAB.
0
Mike Kristensen
Asked:
Mike Kristensen
1 Solution
 
becraigCommented:
Comments can be written

//This is a comment


Multi line comments

    /* This is a multi line comment
      Another comment on another line*/
0
 
Mike KristensenIT administratorAuthor Commented:
Hmmm. Sry. It is as soon as im working inside a state, or something like that. (What you call it?)

Look this:
$form = <<<ENDFORM
<form action=noter.php method=post>
<tr>
<td><input type=submit name=tilføj_note_l value='Tilføj_note_linje' > </td>
</tr>
</form>
ENDFORM;
echo $form;

How to exclude the <td> line? In my file its all grey text for now. Im not sure, but it seems to be the grey text i cant exclude.
0
 
Trenton KnewCommented:
If you cannot edit the region, than you may not be able to comment the line out.  It looks like you're missing your PHP opens and closers though.  The HTML inside a php would kind of not work right.  Look at this:
$form = <<<ENDFORM
/* assuming you are inside a PHP code block here, you close it with this -> */  ?>
<form action=noter.php method=post>
<tr>
<?php /*let's hide this line by opening another php code block and then commenting it out with a double slash */
//<td><input type=submit name=tilføj_note_l value='Tilføj_note_linje' > </td>
/* also need to close that block here too */ ?>
</tr>
</form>
<?php //needs to be reopened here
ENDFORM;
echo $form;
0
 
Marco GasiFreelancerCommented:
When you use heredoc notation, you can't simply comment out a single part of the code. You have to just delete it. Otherwise, if you need to include or exclude some part accordingly to some condition, you have to write two forms:

$form1 = <<<ENDFORM
<form action=noter.php method=post>
<tr>
<td><input type=submit name=tilføj_note_l value='Tilføj_note_linje' > </td>
</tr>
</form>
ENDFORM;
$form2 = <<<ENDFORM
<form action=noter.php method=post>
<tr>

</tr>
</form>
ENDFORM;

if (your condition here)
{
    echo $form1;
}
else
{
    echo $form2;
}

Open in new window

0
 
Mike KristensenIT administratorAuthor Commented:
Thx. I understand the system now.

Or haha. But i understand what i have to do :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now