Strict Standards: Only variables should be passed by reference error
This should be OK
$value = explode(".", $value);
$extension = strtolower(array_pop($value)); //Line 32
// the file name is before the last "."
$fileName = array_shift($value); //Line 34
Only variables should be passed by reference
Assign the result of explode
to a variable and pass that variable to end
:
$tmp = explode('.', $file_name);
$file_extension = end($tmp);
The problem is, that end
requires a reference, because it modifies the internal representation of the array (i.e. it makes the current element pointer point to the last element).
The result of explode('.', $file_name)
cannot be turned into a reference. This is a restriction in the PHP language, that probably exists for simplicity reasons.
Strict Standards: Only variables should be passed by reference [5.6]
Read the PHP doc of end:
The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.
Which means you cannot pass explode
function directly to end
. Instead you need to do in two steps:
$var = explode('-', $url);
$numero = end($var);
PHP Strict Standards: Only variables should be passed by reference in .lib
This error happens because some functions not only return values but also (try to) change passed parameters (these params need to be passed by reference, because otherwise their value would be copied and there would be no effect outside function scope).
For example reset()
returns first element, but also changes internal array pointer (current elemtent). If you pass an array not assigned to any variable (direct result of the function call) the pointer cannot be set, because this array in outer scope doesn't longer exist. To fix line 309
you need to split command into variable assignment and then pass it to reset function:
$event_list = event_list(array('artikul_id' => $event_artikul_ids), ' AND point_id > 0');
$event = reset($event_list);
Same error in line 87
(needs if
with braces though).
The problem in line 155
is caused by html_rating_div_str()
function. For some reason it also requires reference - its definition might look like:
function html_rating_div_str(&$array, $users_data, $string) {...}
...with &
before one of the variables. The referenced parameter should be changed to variable first, and then passed to this function.
end(explode) Strict Standards: Only variables should be passed by reference in
Why not use pathinfo (PHP >= 4.0.3
), i.e.:
$ext = pathinfo($_FILES["rfile"]["name"])['extension'];
Live PHP demo
http://ideone.com/eMpbnL
PHP Strict Standards: Only variables should be passed by reference error
array_pop()
takes an array as a reference and you are passing the return of a function which can't be referenced. See Passing By Reference.
Simply change to:
$array = Article::listAll(new DBEListCriteria(implode(' and ', $conditions), null, new DBEListOffset(1)));
return array_pop($array);
But I would ask, why not sort ORDER BY
the rows in the query and LIMIT
to 1?
PHP Strict Standards: Only variables should be passed by reference in
The problem is this part of your code:
<?php
smarty_block_m3_validate_box($this->_tag_stack[count($this->_tag_stack)-1][1], $this->_block_content, $this, $_block_repeat=false);
You created smarty_block_m3_validate_box
with:
<?php
function smarty_block_m3_validate_box($params, $content, &$smarty, &$repeat)
(Parameter 3 and 4 are passed by reference)
Now you're trying to pass $_block_repeat=false
as the third parameter, which will work, but throws an E_STRICT error (like you get). The solution would be to assign $_block_repeat
with the value you want and pass it to the function:
<?php
$_block_repeat = false;
smarty_block_m3_validate_box($this->_tag_stack[count($this->_tag_stack)-1][1], $this->_block_content, $this, $_block_repeat);
Strict Standards: Only variables should be passed by reference
You can try this code:
<?php
<?php
function scanDirectoryImages($directory, array $exts = array('jpeg', 'jpg', 'png'))
{
if (substr($directory, -1) == 'uploads/') {
$directory = substr($directory, 0, -1);
}
$html = '';
if (
is_readable($directory)
&& (file_exists($directory) || is_dir($directory))
) {
$directoryList = opendir($directory);
while($file = readdir($directoryList)) {
if ($file != '.' && $file != '..') {
$path = $directory . '/' . $file;
if (is_readable($path)) {
if (is_dir($path)) {
return scanDirectoryImages($path, $exts);
}
$path_info = pathinfo($path);
$ext = strtolower($path_info['extension']);
if (is_file($path) && in_array($ext, $exts)) {
$html .= '<a href="' . $path . '"><img src="' . $path
. '" style="max-height:100px;max-width:100px" /></a>';
}
}
}
}
closedir($directoryList);
}
return $html;
}
Related Topics
Custom Order Status Background Button Color in Woocommerce 3.3 Admin Order List
How to Make Pdo Run Set Names Utf8 Each Time I Connect, in Zendframework
Artisan Migrate Could Not Find Driver
How to Password Protect Folder/Page Using PHP Without a Db or Username
Scaling a Chat App - Short Polling VS. Long Polling (Ajax, PHP)
Laravel 4 - Logging SQL Queries
How to Re-Save the Entity as Another Row in Doctrine 2
How to Upload and Parse a CSV File in PHP
How to Add a New Method to a PHP Object on the Fly
MySQL Error: 1364 Field 'Display_Name' Doesn't Have Default Value
Print Newline in PHP in Single Quotes
Regular Expression to Check If the String Has Chinese Chars
PHP Create and Save a Txt File to Root Directory
Differencebetween Sessions and Cookies in PHP
Using If(Isset($_Post['Submit'])) to Not Display Echo When Script Is Open Is Not Working