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

All Questions

Tagged with
3 votes
1 answer
2k views

PSR and constructor visibility

According to PSR-2 Visibility MUST be declared on all properties and methods but what about __construct, it's specific function and I was wondering if it should also be marked by default as ...
logical-luke's user avatar
0 votes
1 answer
290 views

Hide out of stock - "pre_get_post" taxanomy for visibility on shop page

In my WooCommerce store, I have "Hide out of stock items from the catalogue" enabled. This option causes product variations on individual pages to become invisible. I want to apply "Hide out of ...
Jason's user avatar
  • 1,308
2 votes
2 answers
124 views

Why does calling of test() function of Foo class (which extends Bar class) returns result mixed from both classes?

It may sound silly, but I'm new in PHP. I was learning from the documentation about access specifiers when I came to this section. class Bar { public function __construct() { echo "Bar::...
Bivek's user avatar
  • 1,388
6 votes
2 answers
2k views

What's the visibility of a class by default in PHP?

I could find the default visibility of a property and a method in the PHP manual. But i couldn't find any info regarding the class itself. My guess is that it's public. But if someone could link to ...
Jo Smo's user avatar
  • 7,053
2 votes
0 answers
131 views

Why isn't php happy with a public method signature being incompatible with the parent private method signature?

The following piece of code <?php class A { private function test($str = null) { echo $str; } } class B extends A { public function test() { echo 'b'; } } $b = ...
greg0ire's user avatar
  • 23.1k
0 votes
2 answers
1k views

Visibility in Yii2

I'm trying to create a page with a menu which has a different visibility for different users. I have 3 users: Users, Moderators and admins. Could somebody help me with this issue. Here is my code: ...
atze de groot's user avatar
1 vote
1 answer
34 views

Visibility property not working properly with fadeOut()

I am developing a feedback page in a table with 3 columns. Name Feedback icons status ------------------------------------------------- Name1 icon1 icon2 icon3 Saved ...
Techy's user avatar
  • 2,646
0 votes
3 answers
47 views

php variable scope quetion

Here's the code first: <?php $test = 'nothing'; function check_test(){ global $test; echo 'The test is '.$test.'\n'; } function run($lala){ $test = $lala; check_test(); } ...
user3416803's user avatar
-1 votes
1 answer
89 views

Trying to pass number of results variable in php

I am passing an sql query through a function that returns the number of results from a SELECT query. The result is a correct count for the mysqli_num_rows() method but does not set the counter ...
Pj Rigor's user avatar
  • 401
0 votes
1 answer
2k views

Yii2 inputfield set disabled depend other field

I have, a create form, where i ask two things. The first is a user_id the other is a name. I want to achieve that, if the first is set then the other field will be disabled. And if because there i ...
Francis's user avatar
  • 1,835
-1 votes
1 answer
47 views

weird behaviour with protected static properties and inheritance in php

I have a problem with static members and inheritance in php Why this works: class A { public static function me() { echo static::$b; } } class B extends A { protected static $b = "hello"...
cubob's user avatar
  • 61
1 vote
1 answer
192 views

Can't access parent class properties

When i use parent class properties it returns NULL , I have no idea why this happens, Example code : class Foo { public $example_property; public function __construct(){ $this->...
Amin Abdolrezapoor's user avatar
2 votes
1 answer
106 views

In derived classes in PHP, why isn't it an error to assign to private variables declared on the base class?

While going through the PHP code of one of my projects, I noticed something that - I thought - shouldn't work at all. And yet it doesn't result in any errors or notices in either PHP 5.2.17 or 5.6.14....
WalterGR's user avatar
  • 351
1 vote
0 answers
184 views

Override a public function by a private function in php

I am using laravel as framework and I love the Eloquent objects. But now I have an Eloquent object, which only is allowed to be created within specific functions. In normal cases I would make the ...
Jetse's user avatar
  • 1,796
0 votes
2 answers
160 views

protected variables and php __get method

I am a new learner of PHP. I really need help. Caa you see what is the difference here between __get method and getcount() method. I think they both do the same thing, but I wonder if there is an ...
user avatar

15 30 50 per page
1 2
3
4 5
10