All Questions
Tagged with visibility php
142
questions
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 ...
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 ...
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::...
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 ...
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 = ...
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:
...
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
...
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();
}
...
-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 ...
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 ...
-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"...
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->...
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....
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 ...
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 ...