PHP-INTRODUCTION
PHP started out as a small open source project that evolved as more and more people found out how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
- PHP is a recursive acronym for “PHP: Hypertext Preprocessor”.
- PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
- It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.
- PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL server, once started, executes even very complex queries with huge result sets in record-setting time.
- PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.
- PHP is forgiving: PHP language tries to be as forgiving as possible.
- PHP Syntax is C-Like.
Common uses of PHP
- PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
- PHP can handle forms, i.e. gather data from files, save data to a file, through email you can send data, return data to the user.
- You add, delete, modify elements within your database through PHP.
- Access cookies variables and set cookies.
- Using PHP, you can restrict users to access some pages of your website.
- It can encrypt data.
Characteristics of PHP
Five important characteristics make PHP’s practical nature possible −
- Simplicity
- Efficiency
- Security
- Flexibility
- Familiarity
- A function is a reusable piece or block of code that performs a specific action.
Functions can either return values when called or can simply perform an operation without returning any value.
PHP has over 700 functions built in that perform different tasks.
In this tutorial, you will learn-
- Why use Functions?
- Built in Functions
- String Functions
- Numeric Functions
- Date Function
- Why use User Defined Functions?
Why use Functions?
- Better code organization – functions allow us to group blocks of related code that perform a specific task together.
- Reusability – once defined, a function can be called by a number of scripts in our PHP files. This saves us time of reinventing the wheel when we want to perform some routine tasks such as connecting to the database
- Easy maintenance- updates to the system only need to be made in one place.
Built in Functions
Built in functions are functions that exist in PHP installation package.
These built in functions are what make PHP a very efficient and productive scripting language.
The built in functions can be classified into many categories. Below is the list of the categories.
String Functions
These are functions that manipulate string data, refer to the article on strings for implementation examples of string functions
Numeric Functions
Numeric functions are function that return numeric results.
Numeric php function can be used to format numbers, return constants, perform mathematical computations etc.
Some facts about PHP:
- PHP was developed by Rasmus Lerdorf in 1995, and later it has been developed as open source. The PHP Group now manages the implementation of PHP.
- Many syntaxes of PHP is similar to C, Java, and Perl, and has many unique features and specific functions.
- PHP page is a file with a .php extension that contains could be the combination of HTML Tags and PHP scripts.
- PHP recursive acronym for PHP(Hypertext Preprocessor): HyperText means, text containing all sorts of web markups, PreProcessor means all of the HyperText is processed first and then the result is sent as pure HTML to the web browser. A client cannot see the PHP source code because it is preprocessed and interpreted.
- PHP is Server-side scripting language: Server-side scripting means that the PHP code is processed on the web server rather than the client machine.
- PHP supports many databases (MySQL and PHP combination is widely used).
- PHP is an open source scripting language.
- PHP is free to download and use.
- The best things about using PHP is extremely easy for a newcomer, and also it has many advanced features for a professional programmer.
- Learning PHP is very easy, and it runs efficiently on server-side.
- PHP works on many operating systems such as Linux, Windows, Mac OS X.
- PHP is FREE to download from the official PHP resource: php.net
- PHP supports many databases like MySQL, MS SQL, Oracle, Sybase, PostgreSQL and many others.
- PHP can dynamically generate HTML, PDF, Flash, Text, CSV, XML and many others.
- Coding in PHP is easy and fast, so it takes less time to build an application.
- Many good PHP frameworks like Zend, Codeigniter, and Laravel are available in PHP.
- Many web hosting options are available at the fair price with PHP.
- With PHP code deployment is very easy.
- Substantial PHP community support, and many tutorials and sample programs are available online.
PHP vs. Other Technologies
Many developers working in other technologies which are also interested in working in PHP, for example, JSP, ASP, Perl, ColdFusion are the name of few. Usually, it’s a matter of preference and the cost involved that urges developers to pick PHP one over the other. Maybe different opinions about it, but most of PHP developers believe that PHP is easier to learn and has a superior syntax than other languages. Additionally PHP is fast and safe, and on top of all, it’s free.