How to comment HTML code that has PHP in it?

I have HTML code that has PHP in it, and I wanted to comment on it.

<input type="hidden" name="returnurl" value="<?php if (!empty($link)) {echo $link;}?>">

How to comment both HTML and PHP separately without comments?

+5
source share
8 answers

Thanks to Ross Patterson, I found that I did not completely understand this question. So here is the new answer. I leave the old answer below, as it may be useful for some people.

New answer

You can handle it easily, as there are no PHP lines or comments in your code. This means that commenting on this piece of code is as simple as:

<?php
/*
<input type="hidden" name="returnurl" value="<?php if (!empty($link)) {echo $link;}?>">
*/
?>

, , , . :

<div>
  You're logged in.
  <?php
  /**
   * Says "hello" to the person.
   * @param string $name The name of the person.
   */
  function SayHello($name)
  {
    echo 'Hello, ' . $name;
  }

  SayHello($personName);
  ?>
</div>

, 7.

NOWDOC :

<?php
$GUID2328f09280b94c22867d831a885b57eb = <<<'GUID2328f09280b94c22867d831a885b57eb'
<div>
  You're logged in.
  <?php
  /**
   * Says "hello" to the person.
   * @param string $name The name of the person.
   */
  function SayHello($name)
  {
    echo 'Hello, ' . $name;
  }

  SayHello($personName);
  ?>
</div>
GUID2328f09280b94c22867d831a885b57eb
?>

:

  • NOWDOC ?

    5 ( "Says" hello "). 2 (" ").

  • NOWDOC HEREDOC?

    , . , , .

  • GUID2328...?

    GUID, , , -, , , -, . GUID, HEREDOC/NOWDOC , , .

    , , .

  • -, ?

    . , , PHP- , ( ).

, . , . , , ( , ?).


?

  • ? PHP. :

    <?php /** The value is hidden for the moment to be backwards compatible, but the field
            * would be removed in the near future, since having this field presents a
            * security risk. See bug report 1422, http://example.com/bugs/1422 */ ?>
    <input type="hidden" name="returnurl" value="<?php if (!empty($link)) {echo $link;}?>">
    

    , HTML . , , , .

  • ? HTML. :

    <!-- If `returnurl` is null or empty, the client would be redirected to the home page
         of the website. -->
    <input type="hidden" name="returnurl" value="<?php if (!empty($link)) {echo $link;}?>">
    

    , - , , , - -, HTML ( , , , API , HTML-).

, :

  • HTML ,

  • HTML- , . : ; , , Google.

+8

, , .

, PHP html, . :

<?php 
     print '<input type="hidden" name="returnurl" value="';
     if (!empty($link)) {echo $link;}
     print '">';
?>

, , , :

<?php /*
     print '<input type="hidden" name="returnurl" value="';
     if (!empty($link)) {echo $link;}
     print '">';
     */
?>

PHP HTML . HTML. , PHP PHP, HTML PHP, () HTML, .

, .

+2

php HTML-, php, HTML PHP, HTML.

, , .

, , , , . HTML, HTML, php, HTML php. .

+1

:

<?php /*
<input type="hidden" name="returnurl" value="<?php if (!empty($link)) {echo $link;}?>">
*/ ?>

PHP, , , */.

+1
<!-- <input type="hidden" name="returnurl" value="<?php //if (!empty($link)) {echo $link;}?>"> -->

0

( , ).

  • php,
  • .
  • - php, .

,

<input type="hidden" name="returnurl" value="<?php 
/**
a multi line
comment here
*/
if (!empty($link)) {echo $link;}?>">

:

<?php 
echo :<input type="hidden" name="returnurl" value="";
//a multi line
//comment here
//
if (!empty($link)) {echo $link;}
echo ">";
?>

<?php 
/*
echo :<input type="hidden" name="returnurl" value="";
//a multi line
//comment here
//
if (!empty($link)) {echo $link;}
echo ">";*/
?>
0

() ,

<?php if(0) : ?>
...
<?php endif; ?>

. if(0) istead if (0) , .

0

nibra - , .

<?php if(0) : ?>
...
<?php endif; ?>

, , HTML-, PHP, .

0

All Articles