Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday, July 13, 2010

Array Functions (PHP)

I will describe some functions, while we can use it in working with Array.
count(x) = If we write a sequence of variable for x, it will count how many element is in this sequence.
For Example:
$a[4]=10;
$number=count($a);
It will show us how many elements is in this ($a) sequence.
array_pop($sequence) = it is take off the last element of $sequence sequence.
For Example:
$a=array('a','b','c');
echo array_pop($a);
//## c will be in output of this code. It will give to us a last element of this sequence.
array_push($sequence,"elements ") = It is using for adding new elements to the end of the sequence.
For Example:
$a=array("a","b","c");
array_push($a,"d","f");
//## This code add ”d” and “f” to the end of the sequence.

Monday, July 5, 2010

Function of PHP Exit and Die

Mission of this functions is ended working programs. The biggest difference between die function and exit is you can show a message when a program ended by die function.

For Example:
<?php

if($a==10)
{
die("Program was ended");
} else
{
echo "program is continueing"
}


?>


In here, program will be ended because of $a=10 and it will bring string from function of die. If we want to make same example in exit :

<?php


$a=10;
 if($a==10)
{
echo "Program was ended";
 exit();
} else{

echo "Program  is continueing." ;
}

?>


As you see, we have to write echo function. For this reason, we prefer die function. For example, if you have a problem in connection to database, you can show a warning message and you can stop the connection.

Friday, July 2, 2010

Environmental Variables (SERVER FUNCTIONS)

CONTENT_LENGTH : It takes information about POST method from FORM.

DOCUMENT_ROOT : It keeps path.

HTTP_COOKIE : It is variable which keeps cookies .

HTTP_HOST : Host name or Host adress .

Thursday, July 1, 2010

echo("HELLO WORLD");


Information About echo()

This function outputs one or more strings.


Example 1 :



<?php
echo "Hello World";
?>