This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 7 years ago.
I was getting the following error:
Deprecated: Function eregi() is deprecated in /home/herbalhe/public_html/admin/includes/auth.inc.php
So I searched and found that I should be using preg_match() instead of eregi(). So I made the changes and now I am getting this error:
Warning: preg_match(): Unknown modifier 'p' in /home/herbalhe/public_html/admin/includes/auth.inc.php
The code on that line is:
if (preg_match(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) ||
preg_match(".inc.php",$_SERVER['PHP_SELF']))
Any idea what I should now?
It should be:
preg_match("/\.inc\.php$/i", $HTTP_SERVER_VARS['PHP_SELF'])
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:
Warning: preg_match() [function.preg-match]: Unknown modifier '/' [duplicate]
(2 answers)
Closed 8 years ago.
I have a PHP function to validate e-mail fields. In my PHP file, I receive below error:
Warning: preg_match(): Unknown modifier '_' in C:\xampp\htdocs\validator.inc.php on line 28
My PHP file is:
<?php
define("EMAIL_MASK", "^[-!#$%&'*+/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z{|}~])*#[a-zA-Z](-?[a-zA-Z0-9])*(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$");
(...)
function isEmailValid($email)
{
return !empty($email) && preg_match(EMAIL_MASK, $email); <---- This is the line raising the error
}
(...)
?>
What am I doing wrong?
You failed to put the PHP regex delimiters.
define("EMAIL_MASK", "~^[-!#$%&'*+/0-9=?A-Z^_a-z{|}\~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z{|}\~])*#[a-zA-Z](-?[a-zA-Z0-9])*(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$~");
| |
This question already has answers here:
Deprecated: Function split() is deprecated. How to rewrite this statement?
(4 answers)
Closed 9 years ago.
I have a piece of code that's using the split() function. PHP is complaining that the function is deprecated. How can this be converted to a non deprecated split?
if(!empty($vis_settings['url']['urls'])){
$split_urls=split("[\n ]+",(string)$vis_settings['url']['urls']);
You can use preg_split.
$split_urls = preg_split("/[\n ]+/",(string) $vis_settings['url']['urls']);