php function

10
PHP Functions Reber Jahwar M.

Upload: reber-novanta

Post on 22-Feb-2017

216 views

Category:

Software


0 download

TRANSCRIPT

PHP FunctionsReber Jahwar M.

Chosen functions :

ZIP Functions Filesystem Functions Calendar Functions

• The PHP Zip files functions allows you to read and edit or close the ZIP files.

• The ZIP include 10 different functions :Functions Description PHP

Zip_close() Closes a ZIP file 4

Zip_entry_close() Closes an entry in the ZIP file 4

zip_entry_compressedsize() Returns the compressed size of an entry in the ZIP file 4

Zip_entry_compressionmethod() Returns the compression method of an entry in the ZIP file 4

Zip_entry_filesize() Returns the actual file size of an entry in the ZIP file 4

Zip_entry_name() Returns the name of an entry in the ZIP file 4

Zip_entry_open() Opens an entry in the ZIP file for reading 4

Zip_enrty_read() Reads from an open entry in the ZIP file 4

Zip_open() Opens a ZIP file 4

Zip_read() Reads the next entry in a ZIP file 4

ZIP Functions

Note : ZIP functions and the Zip library is not enabled by default and must be downloaded !

<?php

$zip = zip_open("test.zip");

zip_read($zip);

// some code

zip_close($zip);?>

<?php$zip = zip_open("test.zip"); {  while ($zip_entry = zip_read($zip))    {    echo "Name: " .

zip_entry_name($zip_entry) ;    echo "Compressed Size: "    zip_entry_compressedsize($zip_entry);      }  zip_close($zip);  }?>

Examples :

• The PHP filesystem functions allow you to access and manipulate the system files in the PC .

• Filesystem include more than 70 functions basename() Returns the filename component of a path 3

disk_total-space() Returns the total size of a directory 4

Is_excutable() Checks whether a file is executable 3

is_uploaded_file() Checks whether a file was uploaded via HTTP POST 3

stat() Returns information about a file 3

realpath() Returns the absolute pathname 4

is_writable() Checks whether a file is writeable 4

fgetc() Returns a character from an open file 3

Filesystem Functions :

Note :The filesystem functions are default no installation needed to use these functions.

<?php$path = "/CR90/file.php";

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

?>

<?phpprint_r(pathinfo("/CR90/file.txt"));?>

Output :

([dirname] => /CR90[basename] => file.txt[extension] => txt)

Examples :

Output :file.php

• The calendar functions are useful when working with different calendar formats and use it inside the PHP code for some reasons .

• The standard it is based on is the Julian day count .• Julian day count JDC of today is ( 3 February 2013 ) .• If we want to use another type of calendar format we must first

convert to Julian day count, then to the calendar format.

~ The calendar function in PHP include 18 different type of functions :

Calendar :

cal_days_in_month() Returns the number of days in a month for a specified year 4

cal_from_jd() Converts a Julian day count into a date of a specified calendar 4

cal_info() Returns information about a given calendar 4cal_to_jd() Converts a date to Julian day count 4easter_date() Returns the Unix timestamp for midnight on Easter of a specified year 3

GregorianToJD() Converts a Gregorian date to a Julian day count 3JDDayOfWeek() Returns the day of a week 3JDMonthName() Returns a month name 3JDToGregorian() Converts a Julian day count to a Gregorian date 3

Note :The windows version of PHP has built-in support for the calendar extension. So, the calendar functions will work automatically..

Calendar Functions :

Output :

There was 30 days in January 2013

Output :

Sunday

<?php$d=cal_days_in_month(CAL_GREGORIAN,1,2013);echo("There was $d days in January 2013");?>

<?php$jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));echo(jddayofweek($jd,1));?>

Examples :

THANK YOUFOR

LISTENING