Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1999

PHP tags should be closed

    XMLWordPrintable

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Add the missing "?>" to close this tag.
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      PHP
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min

      Description

      In a file mixing PHP and HTML, all PHP tags should be closed. Failure to close a tag in this type of file could lead to unexpected output when the file is processed.

      Noncompliant Code Example

      <?=   // Noncompliant; never closed
      $name = "George";
      
      <p> Hello <?= $name ?>.</p>
      

      Compliant Solution

      <?=
      $name = "George";
      ?>
      
      <p> Hello <?= $name ?>.</p>
      

      Exceptions

      This rule does not apply to files that contain only a single opening tag and no inline HTML.

      See

      • Related: S1780 - Closing tag "?>" should be omitted on files containing only PHP

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ann.campbell.2 Ann Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: