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.
Related
This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 4 years ago.
I've read many threads here about this being deprecated and tried replacing it with preg_match but I don't know php enough to fix the rest of the line.
Been enjoying Fotoholder for years, I would switch to a newer similar single file gallery code but then I would lose all my descriptions in the gallery.
Please help resurrect Fotopholder!
( https://github.com/offsky/Fotopholder )
Here are the 2 parts that have eregi:
if(substr($entry,0,1)!="." && !preg_match("#_cache#i",$entry) && is_dir($path."/".$entry)) {
and the 2nd eregi:
if(substr($entry,0,1)!="." && !eregi("_cache",$entry)) {
Thank you very much for your help.
Deprecated means, that the function eregi() is likely to get deleted from the language.
Please use preg_match().
While you still can use eregi(), at a certain point of time your application might not be able to execute any more.
That said: Your code posted is far to big to get a detailed answer.
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.
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 9 years ago.
I'm following a PHP/AJAX tutorial on form validation. (I'm new to php!).
Could someone explain the syntax of this line:
<?=#$_REQUEST['username']?>
The context is the value attribute of an input field.
I know how $_REQUEST works. I just don't get the <?=# part. I understand <? can be used in lieu of <?php (but isn't always supported!) and <?=$variable?> is special syntax for echoing variables. What does the # symbol do?
Thanks.
Links:
Form validation tutorial
Explanation for special syntax
<?= ?> is the short echo syntax. <?=$var?> is equivalent to <?php echo $var; ?>.
From the PHP manual:
echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.
# is the error suppression operator. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
In short, <?=#$_REQUEST['username']?> will try to print out the value of $_REQUEST['username'] (without ouputting any errors). It's not a good practice and shouldn't be used in your code. If you don't want to display the errors, turn off display_errors in your php.ini configuration and log them instead.
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 9 years ago.
I'm learning object oriented php.
I've come across some code I don't fully understand.
This code is within a class.
1) code that uses #.
For example:
$this->image = #imagecreatefromgif($filename);
Can some one explain the uses of #.
2)
Also it looks like the script is declaring variables in a way i'm not used to (the $var way).
For example:
$this->ext = $size['mime'];
$ext is not declared before this code is used, but it used after it. Does this create an $ext variable within the object?
Thanks guys!!
The # will suppress errors so that no errors will be shown for that expression.
http://php.net/manual/en/language.operators.errorcontrol.php
# is php's error suppression operator you should never use it
You should handle error instead ignoring and advantage would be you will get long notice which is helpful to debug too
And worst case would be below as described in manual
Currently the "#" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "#" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.
# Means "Suppress warning when calling this function".
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!