Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of php.md - Opening and Closing PHP Tags Section #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions wordpress-coding-standards/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,34 @@ Correct (Single Line):
<input name="<?php echo esc_attr( $name ); ?>" />
```

When embedding single lines of PHP within an HTML block, the PHP open and close tags must be on the same line as the PHP code, surrounding it.

Correct:

```php
<div class="hfeed">
<?php while ( have_posts() ) : the_post(); ?>
<article id="someid class="someclass">
<!-- ... -->
</article>
<?php endwhile; ?>
</div>
```

Incorrect:

```php
if ( $a === $b ) { ?>
<some html>
<?php }
<div class="hfeed">
<?php
while ( have_posts() ) : the_post();
?>
<article id="someid class="someclass">
<!-- ... -->
</article>
<?php
endwhile;
?>
</div>
```

<h3>No Shorthand PHP Tags</h3>
Expand Down