Sei sulla pagina 1di 9

1 Array:

<?php

//Creates an Array...

$cars=array("Volvo","BMW","Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>

.................
2 Array fill:

<?php

//Fills an array with values...

$a1=array_fill(1,2,"blue");
print_r($a1);

?>

...................
3 Array intersect:

<?php

//Compare arrays, and returns the matches (compare values only)...

$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("e"=>"red","f"=>"green","g"=>"blue");
$result=array_intersect($a1,$a2);
print_r($result);

?>

................
4 Array merge:

<?php

//Merges one or more arrays into one array...

$a1=array("red","green");
$a2=array("blue","yellow");
print_r(array_merge($a1,$a2));

?>

...............
5 Array pop:
<?php
//Deletes the last element of an array...

$a=array("red","green","blue");
array_pop($a);
print_r($a);

?>

..............
calandar
Functions...........

1- cal_days_in _month:

<?php

//Tells about the days in specified date...

$a=cal_days_in_month(CAL_GREGORIAN,2,1965);
echo "There was $a days in February 1965.<br>";
$a=cal_days_in_month(CAL_GREGORIAN,2,2004);
echo "There was $a days in February 2004.<br>";

?>

..............
2 cal_info:

<?php

//Function Tells about the Calender...

print_r(cal_info(0));

?>

................
3 jddays of weak:

<?php

//returns the Days of Week...

$jb=gregoriantojd(1,13,1998);
echo jddayofweek($jb,1);

?>

.................
4 jdmonth name:

<?php

//returns the Month Name...

$jc=gregoriantojd(1,13,1998);
echo jdmonthname($jc,0);

?>

................
5jdto gregorian:

<?php

//Converts a Gregorian date to a Julian Day Count...

$jd=gregoriantojd(6,20,2007);
echo $jd . "<br>";
echo jdtogregorian($jd);

?>

file
functions...........
1 Base name:

<?php

//Returns the Filename from a path...

$path = "/testweb/home.php";

//Show filename with file extension


echo basename($path) ."<br/>";

//Show filename without file extension


echo basename($path,".php");

?>

..................
2 Disk space:

<?php

//Returns the free space, in bytes, of the specified directory...

echo "Disk Free Space: ";


echo disk_free_space("C:");
echo "<br>.Disk Total Space: ";
echo disk_total_space("C:");

?>

..................
3 is_executable:

<?php

//Checks whether the file is specified executable...


$file = "Flux.exe";
if(is_executable($file))
{
echo ("$file is executable");
}
else
{
echo ("$file is not executable");
}

?>

......................
4 is_written able:

<?php

//Checks that Whether the Specified file is Writable...

$file = "test.txt";
if(is_writable($file))
{
echo ("$file is writeable");
}
else
{
echo ("$file is not writeable");
}

?>

..................
5 Real path:

<?php

//return the Absolute Path name

echo realpath("test.txt");

?>

...................Math
function...........
1 cos:

<?php

//returns the Cosine of Different Numbers...

echo(cos(3) . "<br>");
echo(cos(-3) . "<br>");
echo(cos(0) . "<br>");
echo(cos(M_PI) . "<br>");
echo(cos(2*M_PI));
?>

..............
2 Exp:

<?php

//Return 'e' raised to the power of different numbers

echo(exp(0) . "<br>");
echo(exp(1) . "<br>");
echo(exp(10) . "<br>");
echo(exp(4.8));

?>

.................
3 log:

<?php

//Returns the Natural logarithm of different numbers

echo(log(2.7183) . "<br>");
echo(log(2) . "<br>");
echo(log(1) . "<br>");
echo(log(0));

?>

............
4 max:

<?php

//Find Highest value with Max() Function

echo(max(2,4,6,8,10) . "<br>");
echo(max(22,14,68,18,15) . "<br>");
echo(max(array(4,6,8,10)) . "<br>");
echo(max(array(44,16,81,12)));

?>

.................
5 min:

<?php

//Find lowest value with min() Function...

echo(min(2,4,6,8,10) . "<br>");
echo(min(22,14,68,18,15) . "<br>");
echo(min(array(4,6,8,10)) . "<br>");
echo(min(array(44,16,81,12)));
?>

.......................
6 sin:

<?php

//Return the Sine of Different numbers...

echo(sin(3) . "<br>");
echo(sin(-3) . "<br>");
echo(sin(0) . "<br>");
echo(sin(M_PI) . "<br>");
echo(sin(M_PI_2));

?>

.....................
7 sqrt:

<?php

//Returns the Square Root of Different Numbers

echo(sqrt(0) . "<br>");
echo(sqrt(1) . "<br>");
echo(sqrt(9) . "<br>");
echo(sqrt(0.64) . "<br>");
echo(sqrt(-9));

?>

........................
8 tan:

<?php

//Returns the Tangent of Different numbers...

echo(tan(M_PI_4) . "<br>");
echo(tan(0.50) . "<br>");
echo(tan(-0.50) . "<br>");
echo(tan(5) . "<br>");
echo(tan(10) . "<br>");
echo(tan(-5) . "<br>");
echo(tan(-10));

?>

....................mysqli
function..........

1 close:

<?php
//close a previously opened database connection...

$con=mysqli_connect("localhost","root","","my_db");

// ....some PHP code...

if(mysqli_close($con))
{
echo "Database Connection Closed...";
}
else
{
echo "Database Connection not Closed..";
}

?>

.........................
2 connect:

<?php

//Open a new connection to my Sql Server...

$con = mysqli_connect("localhost","root","","my_db");

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "Connection Established";
}

?>

.........................
3 get_host_info:

<?php

//Return the SQL Hostname and Connection type

$con=mysqli_connect("localhost","root","","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

echo mysqli_get_host_info($con);
mysqli_close($con);

?>

...........................

4 mysqli query:

<?php

//Performs query against Database...

$con=mysqli_connect("localhost","root","","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "Connection Established.<br>";
}

// Perform query

if(mysqli_query($con,"INSERT INTO db_table (Name,Email,Address,City)


VALUES ('Glenn','Glenn@gmail.com','Quagmire_Road',33)"))
{
echo "Query Executed...";
}
else
{
echo "Query not Executed...";
}

mysqli_close($con);

?>

.............................

5 mysqli state:

<?php

//Returns the Current System Status...

$con=mysqli_connect("localhost","root","","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

echo "System status: ". mysqli_stat($con);

mysqli_close($con);

?>

Potrebbero piacerti anche