×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
Geolocation is much more accurate for devices with GPS, like smartphones
localStorage.setItem("key1", "value1");
Getting a Value//this will print the value
alert(localStorage.getItem("key1"));
Removing a ValuelocalStorage.removeItem("key1");
Removing All ValueslocalStorage.clear();
Note: The same syntax applies to the session storage, with one difference: Instead of localStorage, sessionStorage is used
- sessionStorage()
- localStorage()
Local vs. Session
- Session Storage is destroyed once the user closes the browser
- Local Storage stores data with no expiration date
Note: You need to be familiar with basic JavaScript in order to understand and use the API
Value
Specifies how much of the task has been completed
Max
Specifies how much work the task requires in totalStatus: <progress min="0" max="100" value="35">
</progress>
100
- Continue
101
- Switching Protocols
102
- Processing (WebDAV)
...
2xx - Success
200
- OK
201
- Created
202
- Accepted
204
- No Content
206
- Partial Content
...
3xx - Redirection
301
- Moved Permanently
304
- Not Modified
307
- Temporary Redirect
308
- Permanent Redirect
...
4xx - Client Error
400
- Bad Request
401
- Unauthorized
402
- Payment Required
403
- Forbidden
404
- Not Found
405
- Method Not Allowed
406
- Not Acceptable
407
- Proxy Authentication Required
408
- Request Timeout
409
- Conflict
...
5xx - Server Error
500
- Internal Server Error
501
- Not Implemented
502
- Bad Gateway
503
- Service Unavailable
504
- Gateway Timeout
...int
parameter.
If any other type is passed, fatal error will be generatedclass Book {
public $price;
public function price(int $price) {
$this->price = $price;
}
}
$book = new Book;
$book->price('k34');
echo $book->price;
Fatal error: Uncaught TypeError: Argument 1 passed to Book::price() must be of the type int, string given
class Foo {
public function __toString()
{
return "Some text about the OBJECT";
}
}
$foo = new Foo();
echo $foo;
__toString
method gets invoked when we echo or print the objectinterface Talkative {
public function talk();
}
class Cat implements Talkative {
public function talk() {
return 'Woof' . PHP_EOL;
}
}
class Dog implements Talkative {
public function talk() {
return 'Meow' . PHP_EOL;
}
}
class Tortoise implements Talkative {
public function talk() {
return 'Yak yak yak yak ...' . PHP_EOL;
}
}
$cat = new Cat;
$dog = new Dog;
$tortoise = new Tortoise;
echo $cat->talk();
echo $dog->talk();
echo $tortoise->talk();
class Bird{
public $canFly;
public $legCount;
public $className;
public function __construct($canFly, $legCount, $className) {
$this->canFly = $canFly;
$this->legCount = $legCount;
$this->className = $className;
}
public function canFly() {
return $this->canFly;
}
public function getLegCount() {
return $this->legCount;
}
public function getBirdInfo() {
$canFly = $this->canFly() ? 'can fly' : 'can not fly';
return $this->className. ' ' . $canFly . ' and has ' . $this->getLegCount() . ' legs' . PHP_EOL;
}
}
class Pigeon extends Bird{
public function __construct($canFly, $legCount) {
parent::__construct($canFly, $legCount, get_class());
}
}
class Penguin extends Bird{
public function __construct($canFly, $legCount) {
parent::__construct($canFly, $legCount, get_class());
}
}
$pigeon = new Pigeon(true, 2);
$penguin = new Penguin(false, 2);
echo $pigeon->getBirdInfo();
echo $penguin->getBirdInfo();
$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
echo "The 'first' element is in the array";
}