All Questions
Tagged with visibility php
142
questions
1
vote
2
answers
534
views
Visibility of Protected/Private Properties from Other Instances of Same Class
The basic rules of inheritance and visibility go as follows:
Accessing private members from within a class is OK.
Accessing private members from a subclass is not OK.
Accessing private members from a ...
4
votes
3
answers
2k
views
What is the difference between the keyword 'Private' and 'Final'?
Having a confusion between Private and Final in PHP.
For example I have 3 classes:
Class A (parent class)
Class B (child class)
Class C (other class)
What I understand:
A: Public variables and ...
2
votes
2
answers
561
views
How do you override self?
I want to build class that implement a lot of methods based on it's id,
so I want to have one class parent that implement the methods!
and when i want to use this class I will extend it and just ...
1
vote
1
answer
2k
views
When a specific form option is selected a new input appears, using JavaScript [duplicate]
I'm trying to get the following concept working (bare in mind my JavaScript knowledge is minimal).
A select option is provided, with fields like:
email
address
marriage
So on...
When a field is ...
0
votes
1
answer
4k
views
Why I can`t access a protected property from its own class directly?
I am new to PHP. I now learn the visibility scope concept (also known as access modifiers).
I read the following two links also on this forum:
Failed to get an object property that containing ":...
6
votes
1
answer
4k
views
Laravel / Eloquent Model Attribute Visibility
Previously ORM's i've used have mapped database columns directly to class properties which allowed you to specific property visibility, just as you normally would to restrict access to certain ...
4
votes
4
answers
2k
views
How can protected property of a class be visible from a static method in PHP?
I understand OOP. What I understand so far is that private and protected cannot be referenced from outside the class using $this->blah notation. If that is correct, how can the following code work?
&...
0
votes
2
answers
157
views
Why can you call a private method from outside of the object scope?
I am curious as to why this is allowed to work, whereby you can call and successfully execute a private method on an object from outside of the object scope providing you are making the call from a ...
0
votes
1
answer
38
views
PHP providing parameter visible only inslide class
I might not grasp nature of PHP OOP system so that's maybe not impossible but let me ask is there a way to create parameter that's accesible only by methods of this class?
I want to craete 'local' ...
1
vote
1
answer
925
views
can classes have visibility to its namespace only
Is it possible to declare a class to be only visible or usable by other classes inside the same namespace?
example:
namespace Dirtyredz;
class BikeStore{}
private Class Bike{}
I want Bike to only ...
6
votes
3
answers
5k
views
How to prevent usage of public parent methods in child instance in PHP?
So let's say I have classes called parent and child, which will be then used from PHP file called caller.php
class Child extends Parent {
}
class Parent {
public function parentMethod(){
}...
1
vote
1
answer
2k
views
Changing the visibility scope of parent methods in child classes
I've got a Validator class and a UserValidator class which extends from it.
My Validator has a public method setRule(...) with public visibility.
When I extend from it I want to change the ...
1
vote
2
answers
879
views
Create page visible only for admins on simple user system in PHP
I am creating a system where users can add items on a calendar and add reports about competitions. But I want to activate them before they are visible on the website.
I have got a row with kal_active ...
-2
votes
1
answer
557
views
Cause of the error: “Using $this when not in object context protected function”
I get the following error when using the following class in my code:
Using $this when not in object context protected function
Here is my code:
<?php
class Sign {
private $db;
private $...
-2
votes
1
answer
99
views
Visibility JQuery Function (ready(), change()...)
I have 3 Files:
Php file where i include the other two files like this:
<head>
<!-- 1. Javascript File-->
<script src="js/functions.js"></script>
</head>
<...