Login
Remember
Register
PHPOnlineSupport
Questions
Unanswered
Tags
Categories
Ask a Question
Ask a Question
What is the difference between public, private, and protected?
0
votes
809
views
asked
Jun 4, 2021
in
General
by
Nimisha
When and why should I use public, private, and protected functions and variables inside a class? What is the difference between them?
php
function
Your comment on this question:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
1
Answer
0
votes
answered
Jun 4, 2021
by
Abhi
Public
scope to make that property/method available from anywhere, other classes and instances of the object.
Private
scope when you want your property/method to be visible in its own class only.
Protected
scope when you want to make your property/method visible in all classes that extend current class including the parent class.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Related questions
0
votes
1
answer
6.0k
views
What is difference between abstract class and interface classes?
asked
Jan 2, 2018
in
General
by
caki
abstract-class
interface-class
php
0
votes
1
answer
726
views
Difference between get and post on php
asked
May 25, 2021
in
General
by
Tester jjavelin
(
120
points)
php
0
votes
1
answer
1.6k
views
Check where the current time is between a given time limit or not - PHP
asked
May 19, 2016
in
General
by
Mike
php
date
0
votes
1
answer
917
views
What is PEAR in PHP?
asked
Oct 29, 2021
in
General
by
anonymous
php
0
votes
1
answer
12.7k
views
What is phalcon php?
asked
Aug 19, 2016
in
General
by
Shed
phalcon
php
0
votes
1
answer
970
views
What are the different types of PHP variables?
asked
Oct 29, 2021
in
General
by
anonymous
php
All categories
General
(56)
CMS
(21)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Databases
(5)
Categories
All categories
General
(56)
CMS
(21)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Databases
(5)
Most popular tags
magento
php
wordpress
wp
laravel
category
database
module
product
arduino
kohana
js
jquery
admin
date
url
sing
birds
json
javascript
cms
cache
error
configurable
love
mac
xbee
serial1
serial
seo
encrypt
recaptha
phalcon
truncate
fishpig
include
backend
function
email
plugin
post
arduinojson
popup
mongodb
security
migrate
editor
decrypt
python
iot
map
shipping
password
core
log
mage
pear
string
replace
extension
import
php7
form
order
day
google
image
youtube
https
http
customer
syntaxerror
datatables
nested
x-ctu
xctu
pan-id
mesh
coordinator
esp
baud
esp8266
esp32
path-issue
site-links
adblocker
qr-code
barcode
samsung
newsletter
feed
auto-numbering-column
datatable
admin-bar
adminbar
toolbar
address16
address64
301
302
...