我有一些代码 php 错误


I have some code php wrong

我一定错过了一些明显的东西。我是这个新手。OSC 验证中的第 55 行,内容如下

if (preg_match()$mail_pat, $email, $components) {

产生以下错误

Parse error: syntax error, unexpected T_VARIABLE in /home/antony/public_html/osc/includes/functions/validations.php on line 55

任何帮助非常感谢

只要写

if (preg_match($mail_pat, $email, $components)) {

而不是

if (preg_match()$mail_pat, $email, $components) {

事实上,很明显...

您必须在 preg_match 函数中提供参数。

如果模式与给定主题匹配,则preg_match()返回1,如果不匹配,则0返回,如果发生错误,则返回FALSE

因此,请将脚本行更改为以下内容:

if (preg_match($mail_pat, $email, $components)) {

你在做什么是绝对错误的。您应该提供参数以preg_match。您没有将$mail_pat, $email, $components包含在 preg_match(( 中。只需将变量括在 **preg_match** 中即可使您的代码正常工作

if (preg_match($mail_pat, $email, $components)) {

希望这对你有帮助

代码更改为

if (preg_match($mail_pat, $email, $components))