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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ewan dot delanoy at gmx dot fr
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Wed Dec 04 19:01:32 2024 UTC