首页 > 代码库 > strstr and strpos

strstr and strpos

啥也不说  直接上代码:

<?php$email  = ‘name@example.com‘;$domain = strstr($email, ‘@‘);echo $domain; // 打印 @example.comecho ‘<br>‘;$user = strstr($email, ‘@‘, true); // 从 PHP 5.3.0 起echo $user; // 打印 nameecho ‘<br>‘;$user = strpos($email, ‘@‘); // 从 PHP 5.3.0 起echo $user; // 打印 name?> 

看结果:

@example.comname4 

 

strstr and strpos