不推荐使用ereg()函数 [英] Function ereg() is deprecated

查看:125
本文介绍了不推荐使用ereg()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习PHP.因此,在我的Windows 7计算机上安装了WAMP服务器.我正在尝试以下PHP代码:

I have started to learn PHP. So installed WAMP server on my windows 7 machine. I am trying the following PHP code :

<?php
$phrase = "I love PHP";
if (ereg("PHP", $phrase)) {
  echo "The expression matches";
}
?>

在mozilla中尝试此操作时,我得到了输出:

When tried this in my mozilla, I got the output :

Deprecated: Function ereg() is deprecated in C:\wamp\www\learnphp\common.php on line 3
The expression matches

我认为代码是正确的.我无法理解该错误.有人可以解释一下已弃用"在这里的含义吗?以及如何解决此错误?

I think the code is correct. I can't understand the error. Can anybody explain me what this "Deprecated" means here? and how to solve this error?

我的php版本是5.3.0.可能是版本问题吗?

My php version is 5.3.0. can it be version problem?

我在Google上进行了搜索,并在www文件夹中找到了关于include \ file.inc文件的信息.我的www文件夹中没有包含目录.

EDIT : I googled it and found something about include\file.inc file in www folder. I don't have include directory in my www folder.

推荐答案

已弃用"表示PHP 5.3.0不再支持该功能.

"Deprecated" means that PHP 5.3.0 no longer supports that function.

您应该将 ereg()视为不再存在.

You should treat ereg() as not existing anymore.

该功能仍然存在,但仅用于支持使用该功能的现有应用程序.

The function does still exist, but only to support existing applications where it's been used.

编写新代码时,切勿使用不推荐使用的函数.

When writing new code, never use a deprecated function.

请考虑使用 preg_match 函数.

这篇关于不推荐使用ereg()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆