how to solve the ereg function deprecated error [duplicate] - php

This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 3 years ago.
I am working with SEO PHP scripts and I am just following Google SEO scripts. When I used the search terms I got an error like the following:
Deprecated: Function eregi() is deprecated in E:\wamp\www\subgoogle\nusoap.php on line 3876
Deprecated: Function ereg() is deprecated in E:\wamp\www\subgoogle\nusoap.php on line 3896
Deprecated: Function ereg() is deprecated in E:\wamp\www\subgoogle\nusoap.php on line 1451
How should I remove that error function? Is there any need to use a library?

eregi() function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
you can use preg_match().

http://php.net/manual/en/function.eregi.php
Note:
As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE.
You need to convert every use of ereg* to an equivalent function of the preg_* family. Or, as #Srisa rightly points out, look for an updated version of the library/script in question.

error_reporting( 0 ) ;
That's how you can eliminate the symptoms, but to cure the disease you just shouldn't use POSIX regular expressions, change them to PCRE

you may want to check this brunch http://sourceforge.net/projects/nusoapforphp53/
it works for me

Change ereg() to mb_ereg.hope which fixes your error. Good luck!

Related

Eregi replace to? [duplicate]

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);

Deprecated create_function() call [duplicate]

This question already has answers here:
PHP 7.2 Function create_function() is deprecated
(6 answers)
Closed 3 years ago.
I just updated my server to the latest version of php 7.2 and now I have some depreciation warnings. What should I do?
This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.
Here is my code:
if(!array_key_exists('callable', $this->translation_plural)) {
$this->translation_plural['callable'] = create_function('$n', $this->translation_plural['function']);
}
The documentation recommends using anonymous functions. Given that $this->translation_plural['function'] looks like it is a string, you should consider a rewrite.
If you want to get rid of the warning, you can use the following:
$this->translation_plural['callable'] = function($n) { return eval($this->translation_plural['function']); };
This doesn't help your code at all, you are still using eval() which is bad practise. The documentation warns against using it.
The only difference is, create_function() used it internally, now it is very explicit.

Fatal error: Uncaught Error: Call to undefined function ereg_replace() PHP 7 [duplicate]

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()

Deprecated: Function eregi() is deprecated in [duplicate]

This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 9 years ago.
I'm trying to submit values to the database but i get an error message
Deprecated: Function eregi() is deprecated in
C:\wamp\www\OB\admin_add_acc.php on line 20 and 27
Here is the code:
<?php
include 'db_connect.php';
if(isset($_POST['Submit']))
{
$acc_type=ucwords($_POST['acc_type']);
$minbalance=ucwords($_POST['minbalance']);
if (!eregi ("^[a-zA-Z ]+$", stripslashes(trim($acc_type))))//line 20
{
echo "Enter Valid Data for Account Type!";
exit(0);
}
else
{
if (!eregi ("^[0-9 ]+$", stripslashes(trim($minbalance))))//line 27
{
eregi() is deprecated as of PHP 5.3, use preg_match() instead.
Note that preg_match() is only case insensitive when you pass the i modifier in your regular expression.
include 'db_connect.php';
if(isset($_POST['Submit']))
{
$acc_type=ucwords($_POST['acc_type']);
$minbalance=ucwords($_POST['minbalance']);
// Removed A-Z here, since the regular expression is case-insensitive
if (!preg_match("/^[a-z ]+$/i", stripslashes(trim($acc_type))))//line 20
{
echo "Enter Valid Data for Account Type!";
exit(0);
}
else
{
// \d and 0-9 do the same thing
if (!preg_match("/^[\d ]+$/", stripslashes(trim($minbalance))))//line 27
{
}
}
}
From Wikipedia:
Deprecation is a status applied to a computer software feature, characteristic, or practice indicating it should be avoided, typically because of it being superseded.
Take a look at the PHP manual for eregi. As you can see, it has the following warning:
This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
Further down the page there is some advice on what to use instead:
eregi() is deprecated as of PHP 5.3.0. preg_match() with the i (PCRE_CASELESS) modifier is the suggested alternative.
So you can use the preg_match function instead.
You can find the answer here in the manual.Since its a Deprecated function in the php version you are using you will get that warning.Instead of ergi you can use preg_match.See the manual for preg match

how can i solve " Deprecated: Function eregi() is deprecated" error [duplicate]

This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 3 years ago.
i am using php 5.3.0 and i am use wamp server
function is like that
eregi("^[ \f\r\t\n]{0,}(SELECT){1}(.+)$",$this->ss_last_query)
eregi("^[ \f\r\t\n]{0,}(UPDATE|INSERT|DELETE){1}(.+)$",$this->ss_last_query)
Two options
Don't use the ereg* functions (use the PCRE suite instead)
Disable E_DEPRECATED error reporting. See error_reporting()
The best option is #1 as the entire POSIX Extended suite will be removed in a future version.
I can't comprehend how people are still using this. It's been marked for removal for years. Not to mention the pre-deprecated "These functions are inferior!" warning that was up for even longer.
Use the preg_match with the i modifier, which specifies that you want a case insensitive match with your regex.
So you want:
preg_match("/regexhere/i", $str);
error_reporting(E_ALL ^ E_DEPRECATED);
If you must use eregi, but...
preg_match("/^[ \f\r\t\n]{0,}(UPDATE|INSERT|DELETE){1}(.+)$/is", $this->ss_last_query)
should also work.

Categories