PHP comment blocks don't work properly in RapidPHP

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
Post Reply
qbuster
Posts: 9
Joined: Wed Nov 07, 2007 2:50 pm
Location: Alrewas, Staffs UK

PHP comment blocks don't work properly in RapidPHP

Post by qbuster »

Using the block and line comments in RapidPhp as in the following code doesn't work.

Code: Select all

function show_letter_form() {
  global $mymp_title, $mymp_fullname, $mymp_constituency, $postcode, $my_email, $mymp_email;
  $postcode = strtoupper($postcode);
  $my_email = "will@Lurchfield.uk";
  echo "<b>Generate a letter to your MP</b><p>
Enter your name and address, and optionally your telephone number, as you wish them
to appear on the letter. Also add your email address if you would like to send the letter by email to your MP. When you click on <I>Generate Letter</I> your letter will
be displayed in a new window ready for printing, or for you to cut and paste into
your word processor. Don't forget to turn off headers and footers if you are printing it! <I> //This information will not be used without your permission.
</I><p>\n";

echo "<form>
<input>
<input>
<input>
<table><tr>
<td><b>Please enter your personal contact details:</b></td>
</tr>
<tr>
/*
<td>Your MP:</td><td><b>$mymp_title $mymp_fullname ($party)</b></td></tr>
<tr>
*/
<td>Your Constituency:</td><input>
<tr>
<td>Your Name:</td><td><input></td>
</tr><tr>
<td>Address:</td><td><input></td>
</tr><tr>
<td></td><td><input></td>
</tr><tr>
<td></td><td><input></td>
</tr><tr>
<td>Postcode:</td><td><input></td>
</tr><tr>
<td>Telephone:</td><td><input></td>
</tr><tr>
<td>Email:</td><td><input></td>
</tr><tr>
<td><input></td>
</tr></table>
</form><p><hr>\n";
}
The result is that the /* */ and // are seen in preview. Can anyone spot where I am going wrong?

Thanks

Will
User avatar
MikeyB
Top Contributor
Posts: 511
Joined: Fri Jun 09, 2006 10:38 am
Location: UK
Contact:

Post by MikeyB »

Hi Will,

This is not a RapidPHP problem, but just the way programming languages work.

You see the comment tags (/* */ and //) because they are within your echo commands.

PHP (and any other language) will simply ignore any code and commands within an echo or print command, and display the entire contents in the browser.

You could try HTML comment tags (<!-- ... -->) as it will be the browser that will be parsing the code at that point.
Can't try it myself as have no way of testing PHP here.

Code: Select all

function show_letter_form() {
  global $mymp_title, $mymp_fullname, $mymp_constituency, $postcode, $my_email, $mymp_email;
  $postcode = strtoupper($postcode);
  $my_email = "will@Lurchfield.uk";
  echo "<b>Generate a letter to your MP</b><p>
Enter your name and address, and optionally your telephone number, as you wish them
to appear on the letter. Also add your email address if you would like to send the letter by email to your MP. When you click on <I>Generate Letter</I> your letter will
be displayed in a new window ready for printing, or for you to cut and paste into
your word processor. Don't forget to turn off headers and footers if you are printing it! <I> <!-- This information will not be used without your permission. -->
</I><p>\n";

echo "<form>
<input>
<input>
<input>
<table><tr>
<td><b>Please enter your personal contact details:</b></td>
</tr>
<tr>
<!--
<td>Your MP:</td><td><b>$mymp_title $mymp_fullname ($party)</b></td></tr>
<tr>
-->
<td>Your Constituency:</td><input>
<tr>
<td>Your Name:</td><td><input></td>
</tr><tr>
<td>Address:</td><td><input></td>
</tr><tr>
<td></td><td><input></td>
</tr><tr>
<td></td><td><input></td>
</tr><tr>
<td>Postcode:</td><td><input></td>
</tr><tr>
<td>Telephone:</td><td><input></td>
</tr><tr>
<td>Email:</td><td><input></td>
</tr><tr>
<td><input></td>
</tr></table>
</form><p><hr>\n";
}
qbuster
Posts: 9
Joined: Wed Nov 07, 2007 2:50 pm
Location: Alrewas, Staffs UK

Post by qbuster »

MikeyB wrote:Hi Will,

This is not a RapidPHP problem, but just the way programming languages work.

You see the comment tags (/* */ and //) because they are within your echo commands.

PHP (and any other language) will simply ignore any code and commands within an echo or print command, and display the entire contents in the browser.

You could try HTML comment tags (<!-- ... -->) as it will be the browser that will be parsing the code at that point.
Thanks Mikey, that makes perfect sense - I thought it might be down to something I was missing!

Cheers

Will
Post Reply