This is a summarization for all PHP functions with small description and the syntax required for the function and example too.
The summerization categorized into the following:
-PHP Functions - File Manipulation:
>> Date Function
Print Date("j/n/y"); >> (22/3/2002)
print date("h:i:s A"); >> (05:11:19 AM)
>> Basename Function
ashraf.co/help/index.php
echo basname("ashraf.co/help/index.php"); // Print Base name
The Base Name Of the file will be >> index.php
>> Dirname Function
ashraf.co/help/index.php
echo dirname("ashraf.co/help/index.php");
The Dir Name OF the Link will be >> ashraf.co/help
>> CHMOD Function ( Modify Licences & Permission Of Files )
Important Modes 755 for scripts & 777 for folders and files
Chmod("test",0755); // give mode 755 for test Folder.
>> CHOWN Function ( Multiple Users Own Multiple Files and Folders )
chown( User identify , File Or Folder );
>> Copy Function ( Copy file or Folder )
copy("arab1.jpg","arab1.pak"); // Copy arab1.jpg file to arab1.pak
>> Unlink Function ( Delete Specific File )
unlink("arab1.pak"); // notice we put name of the file or it's path.
if it's in another directory.
>> Diskfreespace Function ( The Free Space of the disk )
echo diskfreespace("/"); // we can write a folder name instead /
>> File Function ( Read & Manipulate Result of Files )
$myarry = file('http://www.ashraf.co/index.html');
// read the file index and put it in myarray
>> File_exists ( Check if file exist (return 1) or not ( return Any )
if(file_exists("pic.jpg")
{ echo "File is found"; }
else
{ echo "File doesn't exist"; }
>> Filesize Function ( Check the size of the file we want )
echo filesize ("pic.gif");
>> Fopen Function ( Open the file to can deal with it )
$fp = fopen("File.txt", "r");
$fp = fopen("file.txt", "w");
$fp = fopen("http://www.ashraf.co/file.txt", "w");
$fp = fopen("http://www.ashraf.co/file.txt", "r");
>> Fclose Function ( Close the file opened by fopen function )
$fp = fopen("file.txt","r");
fclose($fp);
>> Fread Function ( After Open file Read some part of the file or whole file)
$fp = fopen("file.txt","r");
$contents = fread($fp,20); // read 20 bytes only from the file.
$fclose($fp);
>> Feof Function ( End of file >> Check if we reach the end of file or not)
feof($fp)
>> Fwrite Function ( Write to the file specific thing )
Fwrite($fp,"My Program"); // My Program is The text we want to write.
>> File Function ( Read Complete file without need for open or close it )
file("http://www.gerainmo.net");
>> Is_dir Function ( Check if Directory found ( return 1 ) or not ( 0 ) )
echo is_dir ("mydirectory");
>> mkdir Function ( Make new directory by name and permission )
echo mkdir("Ashraf",0777); // create Ashraf directory with full access.
>> rmdir Function ( Remove Specific directory )
echo rmdir("Ashraf");
>> rename Function ( Rename specific file or folder )
echo rename ("Ashraf","Adel"); // rename Ashraf file to Adel.
>> realpath Function ( Complete real path for specific file )
echo realpath("Ashraf.txt");
-PHP Functions - Arraies Functions:
>> Array Function ( Create Two or Multi Dimentional Arrays )
$test = Array("A","S","H","R","A","F");
>> Array_count_values ( count repeated values and non repeated
$count = array_count_values($test);
>> print_r Function ( Print the array elments )
print_r($test);
>> array_keys ( Get Keys or names of the elements of the array)
array_keys($test);
>> array_merge ( merge 2 or more arrays in one array only )
$test1 = array ("a","b","c");
$test2 = array ("c","f","g");
$test = array_merge ($test1, $test2);
>> array_pop ( delete laste elment in the array )
array_pop($test);
>> array_push ( Add one or more elements in the end of the array )
array_push($test, "d", "y");
>> array_reverse ( reverse the array from end to the start )
array_reverse($test);
>> array_shift ( Del first element in the array )
array_shift($test);
>> array_unique ( return the array's values distinct without any repeat )
array_unique($test);
>> array_values ( return all the array values in new array )
array_Values($test);
>> asort ( arrange array's elements from small to bigger )
asort($test);
>> arsort ( arrange array's elements from high to low )
arsort($test);
>> Count ( Return the No. of elements in the array )
count($test);
>> in_array ( Check if the value if found in the array or not )
in_array("b",$test); // b is the value.
-PHP Functions - Mathematical Operations:
>> bcadd ( add 2 numbers whatever thier datatype )
bcadd("1.59","9.87",1); // 1 specify how many number after ,
Result: 11.3
bcadd("1.59","9.87654",0); // 0 >> will be integer number.
Result: 10
>> bccomp ( Compare between 2 Numbers )
bccomp("1","1.11111",1); // right no. bigger and one fragment = -1
bccomp("1","1.11111"); // 2 numbers consider equal because no frag
>> bcsqrt ( X power 2 >> El Gazer El Tarb3ie )
bcsqrt("17",3); // result will be 4.123
>> abs ( Return the Real Value of the No. )
print (abs(-13)); // will print the real value will be 13.
>> Max ( Return the maximum value of the sent values )
print (max(2,5,6)); // Print No. 6
>> Min ( the reverse operation of Max function )
>> Ceil ( make the floating number become the next integer number )
print(ceil(13.21)); // result will be 14
>> Log ( get the log of the number )
print(log(20));
-PHP Functions - Variables Manipulation:
>> doublelevel ( convert any numerical datatype to double datatype )
doublelevel($var);
>> Empty ( get sure if the variable empty or not by return t\f )
empty($var);
>> gettype ( know the type of the variable )
gettype("hello"); // String
>> intval ( convert the variable to intger datatype )
intval("13.15cm"); // will be 13
>> is_bool ( check if the variable is Boolean or not )
is_bool($var);
>> is_{DataType} ( Check according the datatype )
>> isset ( Check if the variable has been decalred or not )
isset($var);
>> Settype ( set information type to specific datatype )
settype($myvalue,integer);
>> unset ( delete the variable from the memory )
unset($car);
>> var_dump ( specify the datatype and type of information too )
$a=100;
var_dump($a);
-PHP Functions - Image Manipulation:
>> getimagesize ( get type and dimentions of the image )
>> imagecreate ( create new image and must return in variable )
$im = @imagecreate(50,100);
>> ImageColorAllocate ( define the color used in paint the image )
$colorMagenta=ImageColorAllocate($im,0,0,0); // need image variable.
-PHP Functions - Image Manipulation:
>> ftp_connect ( Establish connection with ftp server and return var. )
$ftp = ftp_connect("ashraf.co")
>> Ftp_login ( login to the server )
$log = ftp_login($ftp,"user","Password");
>> ftp_pwd ( where exactly i am in the path or directories )
$dir = ftp_pwd($ftp);
>> ftp_chdir ( go to specific directory and need variable of connect )
$chdir = ftp_chdir($ftp,"Ashraf")
>> ftp_mkdir ( make directory in the current path )
$mkdir = ftp_mkdir($ftp,"adel")
>> ftp_rmdir ( remove directory in the current path )
$rmdir = ftp_rmdir($ftp,"Ashraf")
>> ftp_nlist ( return list with all files and folder in array shape )
$listf = ftp_nlist($ftp,".")
>> ftp_get ( download file from the server and need connect variable
and transformation type < ASCII or Binary > )
ftp_get($ftp,"/tmp/data.bin","/pub/data.bin",FTP_BINARY);
>> ftp_put ( upload file to the server and the same conditions )
ftp_put($ftp,"/tmp/data.bin","/pub/data.bin",FTP_BINARY);
>> ftp_size ( return size of the file from the server )
$size = ftp_size($ftp."Ashraf.txt");
>> ftp_rename ( rename specific file to another name )
$rename = ftp_rename($ftp,"file.txt","fileto.txt");
>> ftp_delete ( delete specific file on the server )
$delete = ftp_delete($ftp,"file.txt");
>> ftp_site ( send commands to the server )
$send = ftp_site($ftp,"cd");
>> ftp_quit ( close the connection between the server and u )
$close = ftp_quit($ftp);
References:
>> Larry Ullman's "PHP for the World Wide Web" (Peachpit Press)
>> "Teach Yourself PHP4 in 24 Hours" by Matt Zandstra