Req #81058 [Com]: Inedible syntax porridge
| From: | rtrtrtrtrt at dfdfdfdf dot dfd | Date: | Thu, 20 May 2021 11:04:56 +0000 |
| Subject: | Req #81058 [Com]: Inedible syntax porridge | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233912@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81058&edit=1
ID: 81058
Comment by: rtrtrtrtrt at dfdfdfdf dot dfd
Reported by: zmfw1991 at gmail dot com
Summary: Inedible syntax porridge
Status: Not a bug
Type: Feature/Change Request
Package: Compile Warning
Operating System: all?
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
garbage in - garbage out
Previous Comments:
------------------------------------------------------------------------
[2021-05-20 11:02:49] zmfw1991 at gmail dot com
No. This is bug!
[RU]
ÐÑавилÑнее бÑло бÑ
опÑеделÑÑÑ ÑÑо как
ÑинÑакÑиÑеÑкÑÑ Ð¾ÑÐ¸Ð±ÐºÑ Ð¸
вÑдаваÑÑ Ð¿ÑедÑпÑеждение, но
php ÑейÑÐ°Ñ ÑÑо не обнаÑÑживаеÑ,
он не замеÑÐ°ÐµÑ Ð»Ð¸ÑнÑÑ ÑоÑкÑ
Ñ Ð·Ð°Ð¿ÑÑой поÑле if () но пеÑед {}.
ÐдеÑÑ Ð²Ð¾Ð·Ð¼Ð¾Ð¶Ð½Ð¾ неÑвное и
непÑедÑказÑемое поведение,
пÑиÑом ÑÑо вÑÑдли кÑо-Ñо
бÑÐ´ÐµÑ Ð¿Ð¸ÑаÑÑ Ð¸ ожидаÑÑ
коÑÑекÑного Ð¿Ð¾Ð²ÐµÐ´ÐµÐ½Ð¸Ñ Ð¾Ñ
ÑÑÑаннÑÑ
конÑÑÑÑкÑии ÑакиÑ
как: if( expression ); { code }
ÐÑи ÑÑом PHP волне
обнаÑÑживаеÑ
ÑинÑакÑиÑеÑкÑÑ Ð¾ÑибкÑ
здеÑÑ, на Ñлове else:
if ( false );
{
echo 'true';
}
else
{
echo 'true';
}
Ðо еÑли else не Ñказан, Ñо PHP
пÑомолÑиÑ. Я на поиÑк Ñакой
оÑибки Ñбил ÑаÑ, а PHP молÑиÑ
как паÑÑизан, она оÑенÑ
незамеÑна и не бÑоÑаеÑÑÑ Ð²
глаза, но ÑÑо оÑибка вÑÑ Ð¶Ðµ.
------------------------------------------------------------------------
[2021-05-20 10:42:48] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2021-05-20 10:24:52] zmfw1991 at gmail dot com
Description:
------------
Semicolon after Control Structures.
Versions: php8.0.3, maybe php 5.3 and <5
Test script:
---------------
<?php
$arr = ['a', 'b', 'c', 'd'];
error_reporting(E_ALL);
/*----------------------------------------------
example 1
----------------------------------------------*/
echo "<h1>example 1:</h1>\r\n";
foreach ( $arr as $val ); // Semicolon after foreach! Errors not found!
{
echo $val . "<br>\r\n";
}
/*----------------------------------------------
example 2
----------------------------------------------*/
echo "<h1>example 2:</h1>\r\n";
function nope() {}
foreach ( $arr as $val);
nope();
{
echo $val . "<br>\r\n";
}
/*----------------------------------------------
example 3
----------------------------------------------*/
echo "<h1>example 3:</h1>\r\n";
if ( false );
{
echo 'true';
}
/*----------------------------------------------
WHY?
----------------------------------------------*/
echo
"
<h1>WHY?</h1>\r\n
Because <i>foreach</i> and <i>if</i> is Control
Structures?<br>\r\n
These errors can be searched forever and never found. They are invisible.
";
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81058&edit=1