×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
__destruct
method to call and the old object gets deleted
(the same result when we run unset($old_object)
)class User {
public $username;
public $friends = ['Tom','David'];
function __construct($name) {
$this->username = $name;
print $this->username . "'s object is created'\n";
}
function __destruct() {
print $this->username . "'s object is deleted'\n";
}
}
$user1 = new User('Tom');
$user1 = new User('George');
unset($user1);
$user2 = new User('David');
echo "\n\n";
After executing the above code the result will be the following:Tom's object is created'
George's object is created'
Tom's object is deleted'
George's object is deleted'
David's object is created'
David's object is deleted'
In this example when George's object gets created, Tom's object gets deleted immediately.
The reason is that we no longer have Tom's object in $user1
variableminor
and patch
versions of the package but major
will be the specified versioncomposer require "vendor/package:2.*"
mysql -u some_user -p
After running the command, we will be required to enter password
of the mysql user some_user
After that, MySQL console
will be activated where we can run MySQL queriesfile.zip
file into some_folder
foldersudo mv file.zip some_folder/
In this example file.zip
file and some_folder
folder are at the same folder level (they have the same parent folder)db_backup.sql
and locates it to public_html/
directory zip -r db_backup.sql public_html/
Unzips the file zipped.zip
and puts it to the current directoryunzip zipped.zip
xs
to xl
)<div class="row">
<div class="col">
1 of 2
</div>
<div class="col">
2 of 2
</div>
</div>
Three equal width columns<div class="row">
<div class="col">
1 of 3
</div>
<div class="col">
2 of 3
</div>
<div class="col">
3 of 3
</div>
</div>
npm list --global --depth 0
trait
is kind of solution to the famous multiple inheritance
problem in PHP.
Using traits we can access methods from different traits that we use in our classclass Mobile {
public function battery() {
echo 'Battery: MB_06, MF_02, MF_00' . PHP_EOL;
}
}
trait Laser {
public function power() {
echo 'Power: 10 mW' . PHP_EOL;
}
}
trait Projector {
public function range() {
echo 'Range: 2 M' . PHP_EOL;
}
}
class Galaxy extends Mobile {
use Laser;
use Projector;
}
$obj1 = new Galaxy;
$obj1->range();
$obj1->power();
$obj1->battery();
//calling the function in window.onload to make sure the HTML is loaded
window.onload = function() {
var x = document.getElementById("demo");
x.style.color = '#6600FF';
x.style.width = '100px';
};
HTML<div id="demo" style="width:400px">Some text inside this DIV</div>
Note: All CSS properties can be set and modified using JavaScript. We cannot use dashes (-) in the property names: these are replaced with camelCase
versions, where the compound words begin with a capital letter.
For example: the background-color
property should be referred to as backgroundColor
.traits
in the same class, the traits must not have the same method declaredtrait Laser {
public function who() {
echo 'I am a Laser' . PHP_EOL;
}
}
trait Projector {
public function who() {
echo 'I am a Laser' . PHP_EOL;
}
}
class Galaxy {
use Laser;//, Projector;
use Projector;
}
Fatal error: Trait method who has not been applied, because there are collisions with other trait methods on Galaxy