PHP Access Modifiers – Access Modifiers in PHP in Hindi – PHP Me 3 Types Ke Access Modifiers Hote Hai, public , private , protected.
Previous Post Also Read :- PHP Constructor And Destructor
Access Modifiers in PHP in Hindi
Contents
PHP Me Access Modifiers Ka Istemal Data Ko public and private, protected Tarike se Access Karne Ke Liye Kiya Jata Hai And Inhe Ham Ek Ek Karke Example Ke Sath Dekhte Hai |
Public Access Modifiers In PHP
public/Default Ek Tarah Ka Aaisa access modifier Hota Hai, Ki Isko Ham Pure Program Me Kahi Par Bhi Iske Data Ko Access Kar Sakte Hai |
Example:
<?php class Employee{ public $name = "danish"; function ShowName(){ echo "$this->name"; } } $emp = new Employee(); echo $emp->name; // access public data ?>
Output:
danish
Private Access Modifiers In PHP
private Ek Tarah Ka Aaisa access modifier Hota Hai, Ki Isko Ham Class Ke Under Hi Access Kar Sakte Hai |
Example:
<?php class Employee{ private $name = "danish"; function ShowName(){ echo "$this->name"; } } $emp = new Employee(); echo $emp->ShowName(); // access private data ?>
Output
danish
Protected Access Modifiers In PHP
Protected Access Modifiers Ko Ham Class Ke Under And Class Derived Ke Under Access Kar Sakte Hai |
Ise Acche Se Samajhne Ke Liye Aapko PHP Inheritance Ko Acche Se Understand Karna Hoga Ji Ko Next Post Me Aap Read Kar Sakte Hai |
Example:
<?php class Employee{ protected $name = "danish"; function ShowName(){ echo "$this->name"; } } $emp = new Employee(); echo $emp->ShowName(); ?>
Output:
danish
Friends Mujhe Umeed Hai Ki Aapko PHP Access Modifiers In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |
Yadi Aapne HTML Full Course And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |