How can remove duplicate values from an array php

You can use array_unique function in php


<?php
$value 
= array("test","test1","test2","test"); $value array_unique($value); print_r($value); ?> 


Outputs:

Array
(
[0] => test
[1] => test1
[2] => test2
)

how can get current time in mysql

how can get current time in mysql


NOW() using in query u can get current time...


<?php
$update 
mysql_query("UPDATE test SET lastlogin = NOW() WHERE username = 'test'"); ?>

How can check value exit in an array

How can check value exit in an array


 in_array function can use to check value exit in an array


example
<?php
$value1 
= array("test","test1","test2","test4"); $new_value1="test1";
if (
in_array($new_value1,$value1)) { echo "$newvalue is already in the array!"; } ?> 

php shorthand operater

php shorthand operater (.=)

concatenation  example
$test.=$tes1;
same like above
$test=$test.$tes1;

how can make mysql support all language

how can make mysql support all language

ALTER DATABASE MyDb CHARACTER SET utf8;

interpolation with curly braces in php


interpolation with curly braces in php


$test="test2";
Ex:$plan="test1 {$test} test3";

strings in php

strings in php 


String are Sequence of characters that can be treated as a unit assigned to variables,simple specify  php code is to enclose it in quotes

string in php whether single or double

ex:$my='php single string';
$my1="double quotes"

full Text search in mysql

full Text search in mysql 



MySQL supported FULLTEXT indexes 3.23.23.VARCHAR and TEXT Columns that have been indexed with FULLTEXT can be used with special SQL statements that perform the full text search in MySQL.

ALTER TABLE test_tab ADD FULLTEXT(title, body);
Once you have done  FULLTEXT index, you can search it using MATCH and AGAINST statements. For example:

SELECT * FROM test_tab
WHERE MATCH ((title, body) AGAINST ('body content');
The result of this query is automatically sorted by relevancy.

some case not support fulltext index because Full-text indexes can be used only with MyISAM

php ternary operator

php ternary operator


evaluate experssion 1 if experssion one is true evaluate experession 2 otherwise return expression 3

syntax ternary operater
experssion-1?
experssion-2 :
experssion-3

file uploading code in php

file uploading code in php


How to HTML form will work



<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileupload" id="file" />
<input type="submit" name="submit" value="Upload file" />
</form>
 PHP  file code

<?php
if ($_FILES["fileupload"]["error"] > 0)
{
echo "Error code when upload: " . $_FILES["fileupload"]["error"] . "<br />";
}
else
{
echo "Upload file name : " . $_FILES["fileupload"]["name"] . "<br />";
echo "Type of the file: " . $_FILES["fileupload"]["type"] . "<br />";
echo "Size of the file in KB: " . ($_FILES["fileupload"]["size"] / 1024) . "<br />";
echo "Stored in temporary folder : " . $_FILES["fileupload"]["tmp_name"];
move_uploaded_file($_FILES["fileupload"]["tmp_name"],"uploads/".$_FILES["file"]["name"]);
}
?>

how can sending email in php

how can sending email in php


mail() function using for email sending in php

<?php
$from="test@gmail.com";
$to="to@gmail.com";
$subject="Test Mail";
$message="Hi ,<br />".
"test mail <br />".
"Thank You";
$headers = "From: $from\r\nContent-type: text/html";
if(mail($to,$subject, $message, $headers))
{
echo "MAIL SENT SUCCESSFULLY";
}
else
{
echo "SOME ISSUE WITH MAIL SENDING in SERVER";
}
?>

how can Adding line break using PHP

how can Adding line break using PHP

 nl2br()



<?php
echo nl2br("test\n php line break");
?>

terminate script in php

php terminating script


exit() ;
die();

break and continue in php

break command exits the innermost loop construct the contains it
continue command skip to the end of current iteration

break command example in php

for($i=0;$i<10;$i++)
{
if($i%2!=0)
break;
print("$i");
}
continue command example


for($i=0;$i<10;$i++)
{
if($i%2!=0)
continue;
print("$i");
}



switch syntax in php

switch syntax in php


swicth(expression)
{
case value1:
stms1
stms2
break;
case 2:
stms1;
break
.
.
.
default
default stms
}



Find Largest number among 3 numbers using switch case in php


<?php 
	    $a = 11; 
	    $b = 2; 
	    $c = 20; 
	    // Swich allows expression 
	    switch($a>$b AND $b>$c){ 
	        case TRUE: echo "$a is bigger"; 
	                   break; 
	        case FALSE: switch($b>$c){ 
	            case TRUE: echo "$b is bigger"; 
	                       break; 
	            case FALSE: echo "$b is bigger"; 
	                        break; 
	        }     
	    } 
	?>

php supported logical operators

php supported logical operators


and
or
||
&&
!

what are printing functions in php

 printing functions in php


print_r() and var_dump

what are difference between echo and print in php

difference between echo and print in php


The two most construct for printing out put  echo and print,the value returned by print will be 1 if printing was successful otherwise returned 0 if unsuccess,echo is a statement and print is function

php escape sequence

php escape sequence


php offers escape sequence characters (/n), u can add new line middle of string

list of php types

php types



Booleans(ture and false)
Integers(numbers with out decimal)
Floating point numbers
Strings
Arrays
Objects
Resources
NULL
Pseudo-types and variables used in this documentation
Type Juggling

what do u mean by php constants

php constants


which have single value throughout their life time....

define(code,111);

how can check value assign or not in php

isset  that test variable assign or not;

how can comments in php code

how can comments in  php code


c language mutliline comments
/*
test
*/
single line comments
//single line comment
#single line comment

what are the include functions in php

what are the include functions in php


include();
include_once();
require();
require_once();

how can set short open tags in php

short open tags in php


<? ?>


you can set up php.ini file to on,short_open tag function enable for  supported php4...

list of web servers support in php

list of web servers support in php


apache,netscape enterprise server ,xitami

server-side scripting

server-side scripting 
server-side scripting is invisible to user,server side scripting mostly web sites to back end like database..php is server side scripting language..

what are client side technologies

client side technologies




css(cascading style sheet),html
client side scripting(javascript,vb script)
java applets
flash animations