All Questions
Tagged with php visibility
142
questions
1
vote
1
answer
225
views
PHP Error: Cannot access private property
I have a class like this:
class Session {
private Session_Database $db;
public function __construct(){
// Instantiate new Database object
$this->db = new Session_Database();...
1
vote
1
answer
41
views
Why is my class not visible outside the file? [closed]
I have 2 PHP files as part of a website. The first one has the API functions (pre made ready to use requests), and the other one has the code itself that will call the functions from the first one.
...
0
votes
1
answer
743
views
why can't I access a protected method from a private method if the protected ones are inherited by the subclasses?
I do not understand this particular case or what Alexander says.
class instance is not the same as class?
As already Alexander Larikov said that you can't access protected
methods from class instance ...
0
votes
1
answer
2k
views
How to hide when ACF relationship field is empty on Elementor without using a plugin
I have a custom post type called "Product" and I have ACF relationship field called meta_product_hands_on_review to pull related review posts in the product.
I would like to hide a link &...
0
votes
1
answer
68
views
Change visibility of content by header
I need to redirect the user in this code example, so I don't have a option.
But I want to make a Box visible, when the result is success, but I can't echo the visibility by the ID, and I can't find a ...
0
votes
1
answer
118
views
PHP class loaded by child process becomes visible in parent process?
I am trying to add a mechanism for loading classes on demand and then basically unloaded them / being able to reload them. Essentially, each time the class is needed, it should be loaded freshly from ...
0
votes
0
answers
346
views
How to change visibility of any method from a PHP object on runtime?
Ok folks, this is what I'm trying to accomplish here.
I want to call a method each time that another method is called, like a middle man.
I'm aware of these magic methods: __call($method, $args) and ...
1
vote
2
answers
2k
views
Private property in parent class can be accessed and re-assigned through the instance of child class in PHP but protected one can't
I am very confused why $produk1->harga = 500; can still make a change
(or re-assign the value 500) to private $harga property despite private $harga in class Produk has PRIVATE visibility ? $...
2
votes
2
answers
719
views
PHP: understanding $this - calling base class method instead of child method
Reading the PHP.net documentation I stumbled upon a problem that twisted the way I understand $this:
class C {
public function speak_child() {
//echo get_class($this);//D
echo $...
4
votes
1
answer
814
views
Why can child override and access its parent private method?
I'm used to put method as protected in my PHP classes. But playing with private I'm starting to have doubts.
I know that it might be a duplicate but I can't find clarity from the SO-answers I've ...
-1
votes
1
answer
154
views
How handle visibility change of property in class when using serialized objects?
UPDATE:
As someone says this question is a bit unclear. I couldn't really understand it myself. But I did dig up the solution. It's a PHP bug that has been resolved. The server this legacy code runs ...
0
votes
1
answer
536
views
Parent's protected properties inaccessible to child object
I have a parent class I'll be calling 'ParentClass' and a child class (that extends from it) which I'll be calling 'ChildClass'.
ParentClass has protected properties $prop1 and $prop2 which I want ...
0
votes
0
answers
38
views
How to make available only those public methods which are declared in interface?
In Java, for example, this comes out of the box due to static nature of the language. But in PHP this could be also useful especially to keep a code secure and clean from an architectural point of ...
1
vote
1
answer
26
views
PHP7 pthreads3 woes : Unable to increment public property of Threaded class from within an instantiated Worker object
I am confused by the results from the following simplified code.
A Threaded object MyPool is to instantiate a variable number of MyWorker objects. As each MyWorker object is correctly instantiated, ...
2
votes
3
answers
3k
views
Add custom column product visibility to admin product list in Woocommerce 3
I am trying to add a custom column to admin product list with the Catalog Visibility value of the products (basically, I need to know easier which is Hidden and which is not).
My code so far for my ...