PHP

PHP 5.3 으로 올리면서 ereg deprecated 에러가 뜨는 경우

은둔한량 2013. 10. 8. 10:44
반응형

대응 examples:

http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php

if(!eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $str)) {
if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $str)) {

if(!eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $str)) {
if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $str)) {

if (!ereg('^[[:alnum:]]+[[:alnum:].]+$', $name)) {
if (!preg_match('#^[[:alnum:]]+[[:alnum:].]+$#', $name)) {

if (!@ereg('^[[:alnum:]]+[[:alnum:].]+$', $name)) {
if (!@preg_match('#^[[:alnum:]]+[[:alnum:].]+$#', $name)) {


$string = ereg_replace(' +', ' ', trim($string));
$string = preg_replace('{ +}', ' ', trim($string));

ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)))
preg_replace('{2037\z}', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)))

ereg_replace('"', ' ', $pieces[$k])
str_replace('"', ' ', $pieces[$k])

ereg_replace('(' . implode('|', $from) . ')', $to, $string)
preg_replace('{(' . implode('|', $from) . ')}', $to, $string)

ereg_replace('[^0-9]', '', $number)
preg_replace('{\D}', '', $number)

ereg_replace('-language', '-' . $languages[$j]['directory'], $cached_file)
str_replace('-language', '-' . $languages[$j]['directory'], $cached_file)

ereg_replace("\r","",$which_text)
str_replace("\r","",$which_text)

ereg_replace('-language', '-' . $language, $cache_blocks[$i]['file'])
str_replace('-language', '-' . $language, $cache_blocks[$i]['file'])

ereg_replace(",\n$", '', $schema)
preg_replace("{,\n\z}", '', $schema)

ereg_replace("\n#", "\n".'\#', $row)
preg_replace("{\n#}", "\n".'\#', $row)

ereg_replace(', $', '', $schema)
preg_replace('{, \z}', '', $schema)

$pieces = split('[[:space:]]+', $search_str)
$pieces = preg_split("/[\s,]+/", $search_str);

if (ereg('->', $use_function)) {
if (preg_match('{->}', $use_function)) {

if (ereg('^[0-9]$', $char)) $rand_value .= $char;
if (preg('/^[0-9]$/', $char)) $rand_value .= $char;

if (ereg('^[0-9]$', $char)) $rand_value .= $char;
if (preg_match('^[0-9]$', $char)) $rand_value .= $char;

ereg('\.([^\.]*$)', $this->file_src_name, $extension);
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

ereg_replace('[^A-Za-z0-9_]', '', $this->file_dst_name_body);
preg_replace('/[^A-Za-z0-9_]/', '', $this->file_dst_name_body);

eregi('\.([^\.]*$)', $this->file_src_name, $extension);
preg_match('/\.([^\.]*$)/i', $this->file_src_name, $extension);

ereg($startreg['format'], $date, $regs);
preg_match('/'.$startreg['format'].'/', $date, $regs);

eregi ("\@.()+_*^%$#\.[;]", $branchname)
preg_match('/\@.()+_*^%$#\.[;]/i', 'your_second_arument', $branchname)

if (eregi($Match, $_SERVER['HTTP_USER_AGENT']))
if (preg_match('/$Match/i',$_SERVER['HTTP_USER_AGENT']))

if (!eregi('^' . DIR_FS_DOCUMENT_ROOT, $current_path)) $current_path = DIR_FS_DOCUMENT_ROOT
if (!preg_match('#^' . DIR_FS_DOCUMENT_ROOT.'#i', $current_path)) $current_path = DIR_FS_DOCUMENT_ROOT;

$string = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$string);
$string = preg_replace("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/i","",$string)

ereg(‘^([^=]*)=["\']?([^"\']*)["\']?$’,$v,$a3)
preg_match(‘/^([^=]*)=["\']?([^"\']*)["\']?$/’, $v, $a3)

ereg(‘^([^=]*)=["\']?([^"\']*)["\']?$’,$v,$a3)
preg_match(‘/^([^=]*)=["\']?([^"\']*)["\']?$/’, $v, $a3)


ereg('([a-z]{1,2})(-([a-z0-9]+))?(;q=([0-9\.]+))?',$lang,$found);
preg_match_all('/([a-z]{1,2})(-([a-z0-9]+))?(;q=([0-9\.]+))?/', $lang, $found);

$title=ereg_replace(" ", "+", $itemurl);
$title=preg_replace("/ /", "+", $itemurl);


이외 없어진 function 들:

http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php

call_user_method() (use call_user_func() instead)
call_user_method_array() (use call_user_func_array() instead)
define_syslog_variables()
dl()
ereg() (use preg_match() instead)
ereg_replace() (use preg_replace() instead)
eregi() (use preg_match() with the ‘i’ modifier instead)
eregi_replace() (use preg_replace() with the ‘i’ modifier instead)
set_magic_quotes_runtime() and its alias, magic_quotes_runtime()
session_register() (use the $_SESSION superglobal instead)
session_unregister() (use the $_SESSION superglobal instead)
session_is_registered() (use the $_SESSION superglobal instead)
set_socket_blocking() (use stream_set_blocking() instead)
split() (use preg_split() instead)
spliti() (use preg_split() with the ‘i’ modifier instead)
sql_regcase()
mysql_db_query() (use mysql_select_db() and mysql_query() instead)
mysql_escape_string() (use mysql_real_escape_string() instead)
Passing locale category names as strings is now deprecated. Use the LC_* family of constants instead.
The is_dst parameter to mktime(). Use the new timezone handling functions instead.

 

 

반응형