【发布时间】:2012-07-11 07:06:38
【问题描述】:
我是 php 新手。我有以下代码:
$this->image["format"] = ereg_replace(".*\.(.*)$", "\\1", $imgfile);
$this->image["outputformat"] = ereg_replace(".*\.(.*)$", "\\1", $save);
工作正常,但我收到错误已弃用:函数 ereg_replace()。 我想问一下在php中使用不推荐使用的函数是否有任何副作用?如果有其他替代品。我试过 preg 但它也不起作用。在此先感谢:)
【问题讨论】:
-
您也可以使用
$ext = array_pop(explode('.', $file_name))提取文件扩展名 -
但我想将其转换为 preg_replace 能否请您帮我处理替换后的结果代码。
-
这可能只是在您的正则表达式中添加分隔符的问题,其他一切看起来都很好。你试过
preg_replace('/.*\.(.*)$/', '\\1', $imgfile)吗?
标签: php