Monday, 18 June 2012

what's function use to send mail in php ?


<?php// multiple recipients$to  'jafarkhanphp@gmail.com' ', '// note the comma
// subject$subject 'Enter Subjects';// message$message 'you can massage to html formate';// To send HTML mail, the Content-type header must be set$headers  'MIME-Version: 1.0' "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";// Additional headers$headers .= 'To: Mary <to@example.com>, other<other@example.com>' "\r\n";
$headers .= 'Cc: cc@example.com' "\r\n";$headers .= 'Bcc: bcc@example.com' "\r\n";
/*** for attachments use this type header ********************/

 //$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
 //$header .= "Content-Transfer-Encoding: base64\r\n";
 //$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
    $header .= $content."\r\n\r\n";
/******************************************************************/// Mail itmail($to$subject$message$headers);?>

How many types of cookies in php?


There are 2 types of cookies: 
(1) Session Based which expire at the end of the session.
(2) Persistent cookies which are written on harddisk.

    Session cookies expire at the end of the session. This means, 
when you close your browser window, the session cookie is deleted. This 
website only uses session cookies.

    Persistent cookies do not expire at the end of the session.

A session cookie may be created when you visit a site or portion of a
 site. The cookie exists for the duration of your visit. For example, a 
session cookie is created when you use the Personal Login to access 
secured pages. Depending on the settings in your browser, you may have 
the option to deny the session cookie; however, if you deny the cookie 
you may have trouble using the site which relies on that cookie.



PHP provided setcookie() function to set a cookie. This function 
requires upto six arguments and should be called before <html> 
tag. For each cookie this function has to be called separately.
setcookie(name, value, expire, path, domain, security);
<?php
   setcookie("name", "John Watkin", time()+3600, "/","", 0);
   setcookie("age", "36", time()+3600, "/", "",  0);
?>
Here is the detail of all the arguments:

  • Name - This sets the name of the cookie and is stored in an environment variable called HTTP_COOKIE_VARS. This variable is used while accessing cookies.
  • Value -This sets the value of the named variable and is the content that you actually want to store.
  • Expiry - This specify a future time in seconds since 00:00:00 GMT on 1st Jan 1970. After this time cookie will become inaccessible. If this parameter is not set then cookie will automatically expire when the Web Browser is closed.
  • Path -This specifies the directories for which the cookie is valid. A single forward slash character permits the cookie to be valid for all directories.
  • Domain - This can be used to specify the domain name in very large domains and must contain at least two periods to be valid. All cookies are only valid for the host and domain which created them.
  • Security - This can be set to 1 to specify that the cookie should only be sent by secure transmission using HTTPS otherwise set to 0 which mean cookie can be sent by regular HTTP.

Wednesday, 16 May 2012

what is strstr function does?


Ans: the strstr function is extract the datat which you want to search in the target string along with the rest data, if it will find.

exm: $tt= 'jafarkhanphp@gmail.com';
$domain = strstr($tt, '@');
echo $domain; // prints @gmail.com

Thursday, 10 May 2012

Q: Why use at the Rate before any function name in php?


Ans: Some time the function generate error in the screen so to stop this type error you must @ sign before calling function.

Example :@mkdir($config['cache'], 0777, true);

Tuesday, 3 April 2012

how can add two fields name in one fields in mysql
Exp : Id, email= id+name

select id,email from email
output:
id  email
1  test@gmail.com
2  demo@gmail.com


select CONCAT(id,'--->',email) as test from email
output: 
test
1--->test@gmail.com
2--->demo@gmail.com

Saturday, 31 March 2012

Q:what is number_format.


number_format  Format a number with grouped thousands

Q:What is unset.

unset  Unset a given variable

Q: What is nl2b.


nl2br  Inserts HTML line breaks before all newlines in a string

<?php
echo nl2br("Welcome\r\nThis is my HTML document"false);
?>
Welcome<br>
This is my HTML document

Q: How can encrypt and decript in mysql .


AES_DECRYPT() Decrypt using AES
AES_ENCRYPT() Encrypt using AES
$query = "insert into member (spid,uname,pss) values ('$xyz','$username',aes_encrypt('$password','password'))";
$query = "select uname,aes_decrypt(pss,'password') as password from member where spid='$xyz'";

Q:How can get ip address using php


$ip=@$REMOTE_ADDR;
echo "<b>IP Address= $ip</b>";
 IP address= 1.23.174.67

$ip=$_SERVER['REMOTE_ADDR'];

Q: How can get days between two date in php


$days = (strtotime("2005-11-20") - strtotime(date("Y-m-d"))) / (60 * 60 * 24);

Q: How can find out unique number array.


array_unique  Removes duplicate values from an array.
<?php
$input 
= array("a" => "green""red""b" => "green""blue""red");
$result 
array_unique($input);
print_r
($result);
?>

Q: How can reverse strings in php


strrev  Reverse a string
<?php
echo strrev("Hello world!"); // outputs "!dlrow olleH"
?>

Monday, 19 March 2012

Q: how can shorting array in php?


Q: how can shorting array .
Or
Q: What is shorting array 
sortSort an array
<?php
$fruits = array("lemon""orange""banana""apple");
sort($fruits);
foreach ($fruits as $key => $val) {
    echo "fruits[" $key "] = " $val "\n";
}
?>
fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange
arsortSort an array in reverse order and maintain index association
<?php
$fruits = array("d" => "lemon""a" => "orange""b" => "banana""c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
    echo "$key = $val\n";
}
?>
a = orange
d = lemon
b = banana
c = apple
 nextAdvance the internal array pointer of an array
<?php
$transport = array('foot''bike''car''plane');
$mode current($transport); // $mode = 'foot';
$mode next($transport);    // $mode = 'bike';
$mode next($transport);    // $mode = 'car';
$mode prev($transport);    // $mode = 'bike';
$mode end($transport);     // $mode = 'plane';
?>

Q: what is func_num_args() and func_get_arg() in php ?


func_num_argsReturns the number of arguments passed to the function.
<?php
function foo()
{
    
$numargs func_num_args();
    echo 
"Number of arguments: $numargs\n";
}
foo(123);   
?>