PHP EMAIL SEND
manupulation and searching string -
strlen() - its return the length of the string.
strpos() - its return search character position within the string.
strrev() - its return the string with the character reverse.
strstr() - its check wheather the sub string presented on a string or not.
e.g - A = education
B = aeiou
strtolower() - its convert all upper case character to lower.
e.g - $a=strtolower("HELLO WORLD");
output - hello world.
strtoupper() - its convert all lower case latter to upper.
e.g - strtoupper("hello world");
output - HELLO WORLD.
ucfirst() - it changes the first latter in the string in uppercase.
e.g - ucfirst("hello world");
output - Hello world.
ucword() - it returns the first latter of every words in upper case.
e.g - ucword("hello world");
output - Hello World
substr() - the sub string function returns a path of a string and it returns the portion of string specified by the start and length parameter.
substr_replace() - the function replace text within a portion of a string.
e.g -
<?php
$a="good morning abcdef";
$b=substr_replace($a,"bye",5,7);
echo $b;
?>
output - good bye abcdef
parse_url() - the parse url function returns an array of component of url.
e.g -
<?php
$a=parse_url("http://me:secret@example.com:8080/php/test?user=amar#res);
print_r($a);
?>
output- array([scheme]=>http,[host]=>example.com,[port]=>8080,[user]=>me,[pass]=>secret,[path]=>php/test,[query]=>user=amar,[fragment]=>res)
str_count() - this fun count the number of sub string occurances.
e.g -
<?php
$n='this is a number';
echo substr_count($n,'is');
?>
output - 2.
printing function -
echo() - it prints many values at once and put string into html and offer php genrated page then send it ti browser.
e.g -
<?php
$a=5;
$b=10;
echo $a;
echo $b;
?>
output- 5
10
print() - its print only only one value.
e.g -
print("hello");
output- hello
var_dump() - the var_dump() function is use to dispaly structure information (datatype and values) about one or more variables.
e.g-
<?php
var_dump(5);
var_dump(5.3);
var_dump("hello");
?>
output- int =>5,float=>5.3,char=>hello.
print_r() - print_r is use for debugging purpose. it prints the contains of array object and so many things in more or less human relable form.
e.g -
<?php
$a=array(amar,salman,aayan,mubeen);
print_r($a);
?>
output - array{
([0]=>amar,[1]=>salman,[2]=>aayan,[3]=>mubeen)
}
printf() - the printf function output a formatted as string the first argument of a printf function is a formatted string it is mostly use in c language.
e.g -
printf("%d",25);
output - 25
HANDLING EMAIL WITH PHP
EMAIL - email or electronic mail is the fastest method of transferring or massage (called email or email massage) over computer network like the internet. php built in support for creating or sending email massage. in php it is vary easy to send email from within your php script.
php introduce mail function
mail() - php uses mail function to sent mail. this function require three mandatory argument that specifies we recepient mail address the subject of the massage and actual massage additional there are other two optional parameter.
syntax - mail($to,$subject,$massage,$header,$parameter)
check email condition -
if(ereg(^[_a-z0-9]+(\.[_a-z0-9]+)*@[_a-z0-9]+(\.[_a-z0-9]+)*(\.[a-z]{2,3})",$email));
popular protocol gor sending email -
SMTP - Simple Mail Transmission Protocol
POP3 - post office protocol 3
IMAP - Internet Message Access Protocol
emails programs -
write a php script to design a form to accept email from user and validate email address using regular expression.
=>
<html>
<body>
<form method="POST" action="emailregular.php">
Enter email:<input type="text" name="user">
<input type="submit">
</form>
</body>
</html>
$email=$_POST['user'];
$pat="^[_a-z0-9]+(\.[_a-z0-9]+)*@[_a-z0-9]+(\.[_a-z0-9]+)*(\.[a-z]{2,3})$";
if(eregi($pat,$email))
{
echo "$email is valid email ID";
}
else
{
echo "$email is invalid email ID";
}
?>
0 Comments