Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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 ...
Ralph Moran's user avatar
25 votes
1 answer
24k views

Can traits have properties & methods with private & protected visibility? Can traits have constructor, destructor & class-constants?

I've never seen a single trait where properties and methods are private or protected. Every time I worked with traits I observed that all the properties and methods declared into any trait are ...
user avatar
2 votes
0 answers
42 views

How to access the method from trait after changing its visibility in the exhibiting class? [duplicate]

Consider below code : <?php trait HelloWorld { public function sayHello() { echo 'Hello World!'; } } // Change visibility of sayHello class MyClass1 { use HelloWorld { ...
PHPLover's user avatar
  • 12.9k