This question already has an answer here:
reset() - "Strict Standards: Only variables should be passed by reference" [duplicate]
(1 answer)
Closed 3 years ago.
I am new to Mysqli_* and I am getting these errors:
(PHP 4 >= 4.0.5, PHP 5, PHP 7)
preg_replace_callback — Perform a regular expression search and replace using a callback
$url = preg_replace('/\/index.php$/i', '', reset($url = explode('?', $_SERVER['HTTP_REFERER'])));
I've read the PHP site and I am just not seeing something. I've tried using preg_replace_callback and splitting the striing and still not working.
There's no need for the call to reset(), just put the call to explode() there.
$url = preg_replace('/\/index\.php$/i', '', explode('?', $_SERVER['HTTP_REFERER']));
Related
This question already has answers here:
Alternative for deprecated PHP function: eregi_replace [duplicate]
(2 answers)
Closed last year.
can someone show me how to convert this please
eregi_replace(":rolleyes:", "<img src='./images/smilies/icon_rolleyes.gif' border='0'> ", $
i have tried lookin gonline but carnt get my head around it keep getting this error
keep getting
PHP Deprecated: Function eregi_replace() is deprecated in
The eregi_replace function is deprecated as of PHP 5.3. You should use preg_replace with the i modifier instead:
preg_replace('/:rolleyes:/i', '<img src="./images/smilies/icon_rolleyes.gif" border="0">', $var);
This question already has answers here:
Replace preg_replace() e modifier with preg_replace_callback
(3 answers)
Closed 1 year ago.
Given line:
"$className = "MForm" . preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')",$name);"
isn't working with PHP7. I changed it to:
"$className = "MForm" . preg_replace_callback('/(?:^|_)(.?)/',"strtoupper('$1')",$name);"
It seems not to be correct, due to warning printout:
"Warning: preg_replace_callback(): Requires argument 2, 'strtoupper('$1')', to be a valid callback in /.../components/com_proforms/formlib/init.php on line 59"
How can I handle strtoupper('$1') correctly in preg_replace_callback()?
Replace "strtoupper('$1')" with
function($matches) { return strtoupper($matches[1]); }
No quotes around it.
This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 3 years ago.
below code is giving me the fatal error in php 7
$jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']));
is there any way to make it compatible with php 7?
Switch to preg_replaceDocs and update the expression to use preg syntax (PCRE) instead of ereg syntax (POSIX) where there are differencesDocs (just as it says to do in the manual for ereg_replaceDocs).
Your above code should be this way:
$jquery_click_hook = preg_replace("[^A-Za-z0-9]", "", strtolower($value['name']));
ereg_replace function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0. So you must have to use preg_replace() function instead of ereg_replace()
This question already has answers here:
PHP: "... variables can be passed by reference" in str_replace()?
(3 answers)
Closed 7 years ago.
What is causing this error?
Fatal error: Only variables can be passed by reference in /var/www/application
/lib/testing/imageMaker/imageMaker.php on line 24
$x=str_replace ($s1,'',$s2);
$y=str_replace ($s1,'',$s2, 1 ); //Line 24
As described here: PHP Manual: str_replace
count
If passed, this will be set to the number of replacements performed.
You cannot pass the literals and rather pass the reference:
$x=str_replace ($s1,'',$s2);
$y=str_replace ($s1,'',$s2, $count);
echo $count;
This question already has answers here:
Error message "Strict standards: Only variables should be passed by reference"
(6 answers)
Closed 6 years ago.
I'm getting the following error:
Strict Standards: Only variables should be passed by reference in /home/bridgesh/public_html/includes/functions/html_output.php on line 45
From the following lines of code:
44. while ($val = current($new_get)){
45. if($val==end(array_reverse ($new_get)) )$new_getstr.='?'.key($new_get).'='.$val;
46. else $new_getstr.='&'.key($new_get).'='.$val;
47. next($new_get);
48. }
I've read through similar questions & answers on the subject here, but cannot figure out how to break the line down correctly.
end works on a reference to an array, so it expects a variable, that contains an array
array_reverse ($new_get) however is not a variable, but a function call
You have to do:
$reversed = array_reverse ($new_get)
if($val==end($reversed) )$new_getstr.='?'.key($new_get).'='.$val;
Try this:
$new_getstr = http_build_query($new_get);
Documentation