Reputation: 11
first of all I apologize for my English, I know it's not the best... I found more than one post related to my problem, but unfortunately I do not know PHP code, so I'm not able to resolve my ptroblem...
In my website, I wolud like to update PHP to version 7.x.x, but there is an error: Notice: Only variables should be passed by reference in /option-tree/ot-loader.php on line 98
Please, does anybody may hel me to fix this? Below is the line of code that I need to edit.
$path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' );
Thank you.
Upvotes: 0
Views: 183
Reputation: 42915
The issue most likely is that you hand over the result of a function call to the end()
function which expects a variable, since it defines a reference as single argument. A function return value may be an array, but not a variable, for obvious reasons. You have to store the result to be able to use it as a reference:
$someArray =
explode(
get_template(),
str_replace( '\\', '/', dirname( __FILE__ ) )
)
);
$path = ltrim(end($someArray), '/');
Alternatively you could also keep that shorter by using an "inline assignment":
$path = ltrim(
end(
$someArray = explode(
get_template(),
str_replace( '\\', '/', dirname( __FILE__ ) )
)
),
'/'
);
Some personal advice:
try to keep your expressions more simply. Overly complex language constructs are certainly compact, but extremely hard to read and debug. No one wins that way.
also you should never suppress errors or warnings using the @
operator before a function identifier. Such warnings offer important information, you should fix those issues instead of suppressing them.
Upvotes: 2