Solved

Exclude some code in a .php file

Posted on 2014-04-27
5
1,513 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
5 Comments
 
LVL 28

Expert Comment

by:becraig
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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 30

Expert Comment

by:Marco Gasi
Comment Utility
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
Comment Utility
Thx. I understand the system now.

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now