Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
614 views
in Technique[技术] by (71.8m points)

php - Function ereg() is deprecated

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";
}
?>

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

Deprecated: Function ereg() is deprecated in C:wampwwwlearnphpcommon.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?

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

Instead, consider the preg_match function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...