Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#12209 closed defect (bug) (invalid)

Syntax errors in filters

Reported by: mfields's profile mfields Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: filter, variable, syntax
Focuses: Cc:


Could be wrong, but should the "$" be inside the curly braces or does it matter?

Line 536:
$actions = apply_filters("${taxonomy}_row_actions", $actions, $tag);

Line 564:
apply_filters("manage_${taxonomy}_custom_column", , $column_name, $tag->term_id);

Change History (3)

#1 @nacin
14 years ago

  • Milestone Unassigned deleted

It looks weird, but it works. It's a way to define a variable variable.

$foo = 'bar';
$baz = "${foo}";
var_dump( $baz ); // string(3) "bar"
$baz = "{$foo}";
var_dump( $baz ); // string(3) "bar"

Based on a real quick test, it appears to be a negligible difference in performance.

#2 @mfields
14 years ago

nacin - Thanks for the info! I have never seen anything like this before so was prompted to ask.

#3 @dd32
14 years ago

  • Resolution set to invalid
  • Status changed from new to closed

It does look weird at first if you've never seen it. But it is syntactically correct.

It reduces errors too, take this for example:

//Ok, All those look sane, now try:

The braces just make it that much more clearer that the variable name is held within, and that the braces will not appear in the final string..

Note: See TracTickets for help on using tickets.