WordPress: Function Reference/email exists:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: ==Description== This function will check whether or not a given email address (<tt>$email</tt>) has already been registered to a username, and returns that users ID (or <tt>false</tt> if ...)
 
无编辑摘要
第1行: 第1行:
==Description==
==Description==
== 描述 ==
This function will check whether or not a given email address (<tt>$email</tt>) has already been registered to a username, and returns that users ID (or <tt>false</tt> if none exists). See also [[WordPress:Function Reference/username exists|username_exists]].
This function will check whether or not a given email address (<tt>$email</tt>) has already been registered to a username, and returns that users ID (or <tt>false</tt> if none exists). See also [[WordPress:Function Reference/username exists|username_exists]].
这个函数检查是否已经为用户注册了电子邮件地址(<tt>$email</tt>),而且返回用户ID(或者如果不存在电子邮件地址,返回<tt>错误的</tt>)。也看看[[WordPress:Function Reference/username exists|username_exists]]。


== Examples ==
== Examples ==


=== Default Usage ===
=== Default Usage ===
== 例子 ==
===默认用法===


This function is normally used when a user is registering, to ensure that the E-mail address the user is attempting to register with has not already been registered.
This function is normally used when a user is registering, to ensure that the E-mail address the user is attempting to register with has not already been registered.
  <?php if ( email_exists($email) ) { . . . } ?>
  <?php if ( email_exists($email) ) { . . . } ?>
用户注册时,通常使用这个函数,确认用户试图注册的电子邮件地址,还没有注册。


=== Detailed Example ===
=== Detailed Example ===
=== 详细的例子 ===


If the E-mail exists, echo the ID number to which the E-mail is registered. Otherwise, tell the viewer that it does not exist.
If the E-mail exists, echo the ID number to which the E-mail is registered. Otherwise, tell the viewer that it does not exist.
如果电子邮件存在,echo电子邮件注册的ID数字。否则的话,通知访客不存在这个电子邮件。
<pre><?php
<pre><?php
   $email = 'myemail@example.com';
   $email = 'myemail@example.com';
第18行: 第32行:
   else
   else
     echo "That E-mail doesn't belong to any registered users on this site";
     echo "That E-mail doesn't belong to any registered users on this site";
?></pre>
<pre><?php
  $email = 'myemail@example.com';
  if ( email_exists($email) )
    echo "That E-mail is registered to user number " . email_exists($email);
  else
    echo "这封电子邮件不属于这个站点上任何注册的用户";
?></pre>
?></pre>


== Parameter ==
== Parameter ==
== 参数==


{{Parameter|$email|string|The E-mail address to check|required}}
{{Parameter|$email|string|The E-mail address to check|required}}
{{Parameter|$email|string|需要确认的电子邮件地址|required}}


== Return ==
== Return ==
== 返回 ==


* If the E-mail exists, function returns the ID of the user to whom the E-mail is registered.
* If the E-mail exists, function returns the ID of the user to whom the E-mail is registered.
*如果电子邮件存在,函数返回已经注册电子邮件的用户的ID。
* If the E-mail does not exist, function returns <tt>false</tt>.
* If the E-mail does not exist, function returns <tt>false</tt>.
*如果电子邮件不存在,函数返回<tt>错误的</tt>。

2008年7月21日 (一) 10:35的版本

Description

描述

This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (or false if none exists). See also username_exists.

这个函数检查是否已经为用户注册了电子邮件地址($email),而且返回用户ID(或者如果不存在电子邮件地址,返回错误的)。也看看username_exists

Examples

Default Usage

例子

默认用法

This function is normally used when a user is registering, to ensure that the E-mail address the user is attempting to register with has not already been registered.

<?php if ( email_exists($email) ) { . . . } ?>

用户注册时,通常使用这个函数,确认用户试图注册的电子邮件地址,还没有注册。

Detailed Example

详细的例子

If the E-mail exists, echo the ID number to which the E-mail is registered. Otherwise, tell the viewer that it does not exist.

如果电子邮件存在,echo电子邮件注册的ID数字。否则的话,通知访客不存在这个电子邮件。

<?php
  $email = 'myemail@example.com';
  if ( email_exists($email) )
    echo "That E-mail is registered to user number " . email_exists($email);
  else
    echo "That E-mail doesn't belong to any registered users on this site";
?>
<?php
  $email = 'myemail@example.com';
  if ( email_exists($email) )
    echo "That E-mail is registered to user number " . email_exists($email);
  else
    echo "这封电子邮件不属于这个站点上任何注册的用户";
?>

Parameter

参数

Return

返回

  • If the E-mail exists, function returns the ID of the user to whom the E-mail is registered.
  • 如果电子邮件存在,函数返回已经注册电子邮件的用户的ID。
  • If the E-mail does not exist, function returns false.
  • 如果电子邮件不存在,函数返回错误的