top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What are the access control modifiers in PHP?

0 votes
307 views
What are the access control modifiers in PHP?
posted Jun 19, 2014 by Amanpreet Kaur

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Access control modifiers restrict the functions and classes to be accessed. Following are the list of access control modifiers:

Public: This property or method can be accessed from anywhere on the script.

Private: This property or method cannot be accessed from everywhere. It can only be used by the class or the object it is a part of.

Protected: This property or method can be used by the code in the class it is a part of.

Abstract: This property or method needs to be subclassed and cannot be used directly.

Example:

Class employee
{
Public $name;
Private $salary;
}
$emp = new employee;
$emp->name = “emp”;
echo $emp->name;

answer Jun 20, 2014 by Mohit Sharma
Similar Questions
+1 vote

I have the following code to add the appropriate header then redirect but I am still getting an error that this header is missing. What am I doing wrong?

 header("HTTP/1.1 301 Moved Permanently");
 header("Access-Control-Allow-Origin: http://".$_SERVER['HTTP_HOST']);
 $augmentedUrl = $playbackbase."?authTicket=$authTicket";
 header("Location: $augmentedUrl");
+1 vote

Hai, friend anybody explain about the Access Modifiers in C#

0 votes

Do u know about planning or implementing OOP methdology access to array methods in PHP in future. Like show code later:

$a = new Array();
$a->append("hello");
$a->shift();
$p = $a->pop();

$b = Array::fill(fill_char="*", count=20);
$b->pop();
...