Skip to content

Grammar error for (string) embedded variables with complex array subscripts  #1

@sorbits

Description

@sorbits

These two code snippets fail:

Snippet 1

<?php
$str = array("Foo", "Bar");
echo "Name: {$str[($str[1]) ? 1 : 0]}"; // Should echo "Name: Bar"
?>

The text "($str[1" appears highlighted as a syntax error.

Snippet 2

<?php
$insert = mysql_query("INSERT INTO `catalogue` SET
 `model`='{$_POST["page_row{$count}_model"]}',
 `type`='{$_POST["page_row{$count}_type"]}',
 `updated`=UNIX_TIMESTAMP()
;");
?>

Everything in the document after this snippet is treated as a string.

Mailing list thread about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions