?
Solved

Exclude some code in a .php file

Posted on 2014-04-27
5
Medium Priority
?
1,926 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 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