[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Exclude some code in a .php file

Posted on 2014-04-27
5
Medium Priority
?
2,009 Views
Last Modified: 2014-04-28
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
Comment
Question by:Mike Kristensen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40026289
Comments can be written

//This is a comment


Multi line comments

    /* This is a multi line comment
      Another comment on another line*/
0
 

Author Comment

by:Mike Kristensen
ID: 40026293
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
 
LVL 9

Accepted Solution

by:
Trenton Knew earned 2000 total points
ID: 40026341
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
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 40026591
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
 

Author Comment

by:Mike Kristensen
ID: 40027408
Thx. I understand the system now.

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question