PHP is a server-side scripting language and one of the most used languages on the web. The majority of the websites you visit are built with PHP. it is a general-purpose scripting language. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages. PHP is fast, but even better, it’s easy to learn and easy to use for writing web applications. PHP code might be implanted into HTML code, or it very well may be utilized in the mix with different web layout frameworks, web content administration frameworks, and web systems. PHP has in constructed bolster for working as one with MySQL; this doesn’t mean you can’t utilize PHP with other database administration frameworks. You can even now utilize PHP with Postgres Prophet, MS SQL Server, ODBC and so forth. We must save the file with the “.php” extension and PHP development code is enclosed in tags.
PHP has over 700 functions that perform a variety of tasks. Functions can either return values when called or can simply perform an operation without returning any value.
A function is a reusable piece or block of code that plays out a particular activity.
Why we use functions?
- Better code organization – functions enable us to group blocks of related code that play out a particular task.
- Reusability – once defined, a function can be called by a number of scripts in our PHP files. This saves us the 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
- A PHP array is a variable that stores in excess of one piece of related information in a single variable. Think of an array as a box of chocolates with spaces inside. The box represents the array itself while the spaces containing chocolates represent the values stored in the arrays.
PHP in Object Oriented Programming (OOPs) concept
Object Oriented is an approach to software development that models application around real world objects such as employees, cars, bank accounts, etc. A class defines the properties and methods of a real world object. An object is an occurrence of a class.
The three basic components of object orientation are;
- Object-oriented analysis – functionality of the system
- Object-oriented designing – the architecture of the system
- Object-oriented programming – implementation of the application
Object Oriented Programming Principles
The three major principles of OOP’s are Encapsulation, Inheritance
- Encapsulation- The main use of encapsulation is to Reduce software development complexity by hiding the implementation details and protect the internal state of an object.
- Inheritance- It tells the relationship between classes.The relationship is a form of parent and child. The child uses the methods defined in the parent class.The main purpose of inheritance is; Re-usability– a number of children, can inherit from the same parent. This is very useful when we have to provide common functionality such as adding, updating and deleting data from the database.
- Polymorphism – This is concerned with having a single form but many different implementation ways. The main purpose of polymorphism is to simplify maintaining applications and making them more extendable.
- PHP is an object-oriented scripting language; it supports all of the above principles.