This is bssn's weblog, which is about Bssn's Internet Life, IT information, webmaters and etc.

php to learn three notes: string operation

A few days ago, read in part, it was another day, this afternoon is important to read these:
Remove spaces and other special symbols: trim, ltrim, rtrim
Removal of accession to the backslash: addcslashes, stripcslasher
Html generated elements: htmlentities, html_entity_decode
Decomposition string: split
String format: sprintf
Acquisition and replacement substring: substr, substr_replace
Length of the string demand: strpos
Positioning characters: strlen
String comparison: strncmp

The following are written in their own email to determine whether or not the correct format and replace the correct e-mail address suffix for yahoo

<?
function mails($email){
list($username,$mail)=split(’[@]‘,$email);
$check1 = strpos($email,’@');
$check2 = substr($email,$check1 1);
$check3 = strlen($check2);
$email1 = substr_replace($mail,’yahoo’,0,strpos($mail,’.'));
/*$a=strcmp($check1,0);
$b=strcmp($check2,0);
if ($a > 0 and $b > 0) {*/
if ($check1 > 0 and $check3 > 0) {
echo $username.’@’.$email1.’<br>’;
}
else
echo "Email address is not correct.<br>";
}
mails("from2004.com@ysdfdf.com");
mails("rrdsfd.com");
?>

Log-related

Leave a Reply