tamil96;11064685 wrote:What is the use of library files in Web development?
hi..
I am new to PHP language. My projects are to create a website using PHP language. I would like to know what are the uses of library functions of PHP in web development process.
Hello, and welcome to PHPBuilder.
In your title, you ask about library files, but the question itself references library functions. You should, perhaps, first clarify exactly what you are asking about.
Secondly, there is, generally, no standard definition of "library files" within PHP itself. That said, much of PHP's functionality comes from its inclusion of several software libraries (e.g. "libxml", "zlib", etc.) and software "extensions", which vary from installation to installation and are generally selected by the installer/sysadmin at compile/install time, but in certain situations can be added later.
However, within software the notion of a "library" is fairly standardized ... it's a resource you can use "something" from when needed. PHP itself includes a vast "library" of functions in most any installation (looking at a production box here I count 1500+ "built-in" PHP functions). Now suppose I need something PHP doesn't provide (let's say, the ability to read and write Microsoft Excel files). Then I might search the internet for some software that runs under PHP that I can use. I might find PHPExcel ('A pure PHP library for reading and writing spreadsheet files'), download it, and include it in an application I'm developing.
Well, as a matter of fact I HAVE done just that (you knew that was coming, right? 😉 ), and here's the top part of the main PHPExcel file. You'll note that it's formulated as a PHP "class":
/**
* PHPExcel
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PHPExcel)
*/
class PHPExcel
{
/**
* Document properties
*
* @var PHPExcel_DocumentProperties
*/
private $_properties;
/**
* Document security
*
* @var PHPExcel_DocumentSecurity
*/
private $_security;
Here's a snippet in which I use the PHPExcel software in my application:
/* get our EXCEL thing up and running */
include "includes/PHPExcel.php";
$count = count($pieces);
if ($count > 200 && $count < 35000)
{
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
}
if ($count >= 35000)
{
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
$cacheSettings = array('dir' => '/usr/home/me/Excel_Cache_Tmp');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
}
if ($_POST['download07']) {
$template_file = "includes/download_Form.xltx"; //modern Excel template
} else {
$template_file = "includes/download_Form.xlt"; //older one
}
$objPHPExcel = PHPExcel_IOFactory::load($template_file);
So, I'm using the PHPExcel software "library" in my application. And that's one example of how libraries are used.