Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
abstract class Fruit { 
    private $color; 
    
    abstract public function eat(); 
    
    public function setColor($c) { 
        $this->color = $c; 
    } 
} 

class Apple extends Fruit {
    public function eat() {
        echo "Omnomnom";
    }
}

$obj = new Apple();
$obj->eat();
In this example an
interface
would not be able to have method with definition, only method signatures are allowed in interfaces
by Valeri Tandilashvili
4 years ago
0
PHP
OOP
1
Guitar implements IMusician interface
interface IMusician {
    public function play();
}

class Guitarist implements IMusician {
    public function play() { 
        echo "playin a guitar";
    }
}
In this example
Guitarist
child class has to define
play()
method because the child class implements interface
IMusician
that has the method signature
by Valeri Tandilashvili
4 years ago
0
PHP
OOP
1
An interface can extend another interface in the same way that a class can extend another class
Interface IBar {
    public function method3();
}

Interface IArray {
    public function method2();
}

Interface IFoo extends IBar, IArray {
    public function method1();
}

class class1 implements IFoo {
    public function method1() {
        
    }
    public function method2() {
        
    }
    // public function method3() {
        
    // }
}
Class
class1
implements
IFoo
interface which extends other two interfaces itself. Because the class has not implemented
method3
method (commented), then the following error will be generated:
Fatal error:  Class class1 contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (IBar::method3)
by Valeri Tandilashvili
4 years ago
0
PHP
OOP
2
Problem: Consider adding
preconnect
or
dns-prefetch
resource hints to establish early connections to important third-party origins. For example to pre-connect google analytics:
https://www.google-analytics.com
we should include
rel
attribute with
preconnect
value:
<link rel="preconnect" href="https://www.google-analytics.com" crossorigin>
in
head
tag
by Valeri Tandilashvili
4 years ago
0
HTML
lighthouse
1
Solution to the problem was to add labels for the inputs but hidden by
CSS
/* Fix to pass Lighthouse: */
.label-hidden {
    position: absolute;
    height: 1px;
    width: 1px;
    clip: rect(1px,1px,1px,1px);
    border: 0;
    overflow: hidden
}
Another solution to the problem:
/* Fix to pass Lighthouse: */
label-hidden { 
    position: absolute; 
    top:-1000px; 
    left:-1000px; 
}
by Valeri Tandilashvili
4 years ago
0
HTML
lighthouse
1
Solution to the problem - to use
aria-label="Twitter"
attribute on
a
tag
<a href="<?=$hostname?>" aria-label="Sibrdzne" class="bg-logo"></a>
by Valeri Tandilashvili
4 years ago
0
HTML
lighthouse
1
jQuery vulnerabilities
Older version of jQuery library has XSS vulnerabilities (lighthouse) Because of that
jquery-1.7.2.min.js
was replaced by
jquery-3.5.1.min.js
by Valeri Tandilashvili
4 years ago
0
jQuery
lighthouse
1
noreferrer on links
Links to cross-origin destinations were not safe (
lighthouse
) Advice: Add
rel="noopener"
or
rel="noreferrer"
to any external links to improve performance and prevent security vulnerabilities
<a class="a_" rel="noreferrer" href="http://orthodoxy.ge" target="_blank" title="მართლმადიდებლური საიტი orthodoxy.ge">orthodoxy.ge</a>
Links that the
noreferrer
was used:
orthodoxy.ge
teodore.ge
qadageba.ge
by Valeri Tandilashvili
4 years ago
0
HTML
lighthouse
1
Fetches all HTTP headers from the current request
print_r(json_encode(getallheaders()));
The result of the above code is:
{
    "Content-Type": "application/json",
    "User-Agent": "PostmanRuntime/7.26.8",
    "Accept": "*/*",
    "Postman-Token": "a89b677d-776a-45d7-988c-f18ad2512522",
    "Host": "localhost",
    "Accept-Encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
    "Content-Length": "137"
}
by Valeri Tandilashvili
4 years ago
0
PHP
functions
1
calculate age based on the provided date of birth
function age($dob) {
    // Seconds in a year
    $seconds = 31556926;

    // Calc. age based on the provided date_of_birth val
    $age = floor((time() - strtotime($dob)) / $seconds);

    return $age;
}
by Valeri Tandilashvili
4 years ago
0
PHP
1
Results: 1578