rspec/rules/S1757/php/rule.adoc

49 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
The `<?php` tag is used to explicitly mark the start of PHP code in a file.
It is considered the recommended and portable way to open PHP blocks.
On the other hand, the `<?=` tag is a shorthand for `<?php` echo and is specifically used to output variables or expressions directly without using the echo statement.
Not using these tags can make the code less readable and harder to maintain, as it deviates from the standard conventions followed by most PHP developers.
2021-04-28 16:49:39 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
[source,php,diff-id=1,diff-type=noncompliant]
2021-04-28 16:49:39 +02:00
----
<?
$foo = 1;
?>
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
[source,php,diff-id=1,diff-type=compliant]
2021-04-28 16:49:39 +02:00
----
<?php
$foo = 1;
?>
----
== Resources
=== Documentation
* https://www.php.net/manual/en/language.basic-syntax.phptags.php[PHP Manual - PHP tags]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]