[go: up one dir, main page]

0% found this document useful (0 votes)
31 views10 pages

4.4 Slides - Built-In Functions

This document discusses built-in PHP functions. It covers advantages of functions like code reusability and readability. It also describes functions for arrays, dates, files, directories, JSON, XML, and ZIP files. For many functions, no installation is needed as they are part of the PHP core, but some may require enabling extensions.

Uploaded by

Meena M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views10 pages

4.4 Slides - Built-In Functions

This document discusses built-in PHP functions. It covers advantages of functions like code reusability and readability. It also describes functions for arrays, dates, files, directories, JSON, XML, and ZIP files. For many functions, no installation is needed as they are part of the PHP core, but some may require enabling extensions.

Uploaded by

Meena M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

SUBJECT CODE

TYPE THE SUBJECT NAME HERE

UNIT NO 4
PHP and XML

● Built-in functions

III V

20CSPC501
INTERNET PROGRAMMING
20CSPC501
INTERNET PROGRAMMING

PHP Built In Functions

PHP function
● piece of code that can be reused many times.
● thousands of built-in functions in PHP

Advantages

● Code Reusability: PHP functions are defined only once and can be
invoked many times, like in other programming languages
● Less Code: It saves a lot of code because you don't need to write the
logic many times. By the use of function, you can write the logic only once
and reuse it.
● Easy to understand: PHP functions separate the programming logic. So it
is easier to understand the flow of the application because every logic is
divided in the form of functions.
20CSPC501
INTERNET PROGRAMMING

PHP Built In Functions


20CSPC501
INTERNET PROGRAMMING

Creating a Function

While creating a user defined function we need to keep few things in


mind: 
 
1. Any name ending with an open and closed parenthesis is a function.
2. A function name always begins with the keyword function.
3. To call a function we just need to write its name followed by the
parenthesis
4. A function name cannot start with a number. It can start with an
alphabet or
underscore.
5. A function name is not case-sensitive.
20CSPC501
INTERNET PROGRAMMING

Date Function

The date function is used to format Unix date and time to human


readable format.
Check the article on PHP date functions for more details.
Other functions
These include;
Arrays – see the article on arrays for examples
Files – see the article on files for examples
Database functions
20CSPC501
INTERNET PROGRAMMING

Build in Functions

PHP Array Introduction


The array functions allow you to access and manipulate arrays.
Simple and multi-dimensional arrays are supported.
Installation
The array functions are part of the PHP core. There is no installation needed to
use these functions.
PHP Calendar Introduction
The calendar extension contains functions that simplifies converting between
different calendar formats.
It is based on the Julian Day Count, which is a count of days starting from
January 1st, 4713 B.C.
Note: To convert between calendar formats, you must first convert to Julian
Day Count, then to the calendar of your choice.
Note: The Julian Day Count is not the same as the Julian Calendar!
Installation
For these functions to work, you have to compile PHP with --enable-calendar.
The Windows version of PHP has built-in support for this extension.
20CSPC501
INTERNET PROGRAMMING

Build in Functions

PHP Date/Time Introduction


The date/time functions allow you to get the date and time from the server
where your PHP script runs. You can then use the date/time functions to format
the date and time in several ways.
Note: These functions depend on the locale settings of your server. Remember
to take daylight saving time and leap years into consideration when working
with these functions.
Installation
The PHP date/time functions are part of the PHP core. No installation is
required to use these functions.
Runtime Configuration
The behavior of these functions is affected by settings in php.ini:
PHP Directory Introduction
The directory functions allow you to retrieve information about directories and
their contents.
Installation
The PHP directory functions are part of the PHP core. No installation is required
to use these functions.
20CSPC501
INTERNET PROGRAMMING

Build in functions
PHP Filesystem Introduction
The filesystem functions allow you to access and manipulate the filesystem.
Installation
The filesystem functions are part of the PHP core. There is no installation needed to use
these functions.
Unix / Windows Compatibility
When specifying a path on Unix platforms, a forward slash (/) is used as directory
separator.
On Windows platforms, both forward slash (/) and backslash (\) can be used.

PHP JSON Introduction


The JSON extension implements the JavaScript Object Notation data-interchange format.
In PHP 5, the decoding is handled by a parser based on the JSON_checker by Douglas
Crockford.
PHP 7 has a new and improved parser specifically written for PHP and licensed under the
PHP license.
Installation
From PHP 5.2.0, the JSON functions are enabled by default. There is no installation
needed to use these functions.
20CSPC501
INTERNET PROGRAMMING

Build in Functions
PHP libxml Introduction
The libxml functions and constants are used together with SimpleXML, XSLT and DOM
functions.
Installation
These functions require the libxml package. Download at xmlsoft.org

PHP SimpleXML Introduction


SimpleXML is an extension that allows us to easily manipulate and get XML data.
SimpleXML provides an easy way of getting an element's name, attributes and textual
content if you know the XML document's structure or layout.
SimpleXML turns an XML document into a data structure you can iterate through like a
collection of arrays and objects.
Installation
From PHP 5, the SimpleXML functions are part of the PHP core. No installation is required
to use these functions.
20CSPC501
INTERNET PROGRAMMING

Build in functions
PHP Stream Introduction
Streams are the way of generalizing file, network, data compression, and other operations
which share a common set of functions and uses. In its simplest definition, a stream is a
resource object which exhibits streamable behavior. That is, it can be read from or written
to in a linear fashion, and may be able to fseek() to an arbitrary location within the stream.
A wrapper is additional code which tells the stream how to handle specific
protocols/encodings.

PHP Zip Introduction


The Zip files functions allows you to read ZIP files.
Linux Systems
For these functions to work, you have to compile PHP with --enable-zip.
PHP 5.6: Use the --with-libzip=DIR configure option to use a system libzip installation.
libzip version 0.11 is required, with 0.11.2 or later recommended.
PHP 7.3: Building against the bundled libzip is discouraged, but still possible by adding --
without-libzip to the configuration.
Windows Systems
Before PHP 5.3: Users must enable "php_zip.dll" inside of "php.ini" for these functions to
work.
From PHP 5.3: The ZIP extension is built-in.

You might also like