Reputation: 1
Could someone please help me check the syntax in the following code and why this is giving an error?
I've tried updating one of my Wordpress files to use the new syntax for function:
{
$if = function(){
return {$values['if']};
};
if ($if()) {
$key = $oid;
$id = get_queried_object_id();
if ($id and $values['with-id']) {
$key = "{$key}_{$id}";
}
break;
}
}
instead of
{
$if = create_function(
'',
"return {$values['if']};"
);
if ($if()) {
$key = $oid;
$id = get_queried_object_id();
if ($id and values['with-id']) {
$key = "{$key}_{$id}";
}
break;
}
}
I tried various combinations of adding ";" , however I'm still getting the error: Parse error: syntax error, unexpected token "{", expecting ";".
Upvotes: 0
Views: 770
Reputation: 18250
This part of the code:
$if=create_function('',"return {$values['if']};");if($if())
is just a complicated way to do a simple test:
if($values['if'])
Upvotes: 1