php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73420 unsemicoloned expressions vs statements
Submitted: 2016-10-30 13:31 UTC Modified: 2020-03-15 22:32 UTC
From: ewan dot delanoy at gmx dot fr Assigned:
Status: Verified Package: PHP Language Specification
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-10-30 13:31 UTC] ewan dot delanoy at gmx dot fr
Description:
------------
    Consider the following (valid) one-line php code :

<input type="<?php echo 'text' ?>"/>

   According to https://github.com/php/php-langspec/blob/master/spec/04-basic-concepts.md, in the code above echo 'text' must be a statement-list.
  
   According to https://github.com/php/php-langspec/blob/master/spec/11-statements.md, this statement-list must in fact consist of a single statement.

  But what type of statement is it ? If we look at the enumeration at https://github.com/php/php-langspec/blob/master/spec/11-statements.md#general, it seems to be an expression-statement. But https://github.com/php/php-langspec/blob/master/spec/11-statements.md#expression-statements says that expression-statements always end with a semicolon.


   

Test script:
---------------
<input type="<?php echo 'text' ?>"/>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-15 22:32 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Documentation Problem +Type: Bug
 [2020-03-15 22:32 UTC] cmb@php.net
> […] it seems to be an expression-statement.

Well, looks more like an echo-statement, but that's not really the
point anyway.  The relevant omission from the language
specification is that a semicolon is automatically inserted before
an PHP end tag[1].  To let that be valid syntax, an
empty-statement would also have to be defined (and is needed
anyway).

[1] <https://github.com/php/php-src/blob/php-7.4.3/Zend/zend_language_scanner.l#L2216>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC