PHP Function | Object-Oriented Programming

Category: Design & Development PHP Web Development
PHP Function | Object Oriented Programming

PHP Function: A function is a block of code written in a program to Display out some particular errand. The defined function can be re-usable. It lessens the time and exertion of redundancy in a single code. If anything code need can be changed, we can easily change inside a function the changes will reflect anywhere we call the function.

Types of Functions in PHP

Built-in: These capacities are now coded and put away in the type of capacities. simply need to call them according to our necessity. for ex:- print_r(),
User-defined: PHP allows us to own a defined function called the user-defined function. Utilizing this we can make our block code and use it simply anywhere by calling it.
How can we declare own function;
syntax, function function_name(){} 
How many types of user-defined function:

Return Type
Parameterized type
Return and parameterized type
PHP Classes/Objects is a programmer-defined data type and class is a collection of objects. Class is a collection of objects and object store its properties and behavior. It contains class objects and functions that perform a block of code.

How we can declare own class;

class class_name{}
Scope of classes in PHP

Public: There methods and properties are accessible anywhere (outside the class)
Private: There methods and properties only accessed within where the class created
Protected: Methods and properties can be accessed inside the class where they are declared.