Results: 1021
Assigning new object to a variable causes
__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
variable
Installs the latest
minor
and
patch
versions of the package but
major
will be the specified version
composer require "vendor/package:2.*"
MySQL command line
Activates MySQL console
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 queries
move file to another directory
Moves
file.zip
file into
some_folder
folder
sudo 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)
zip / unzip file or folder
Zips .sql file
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 directory
unzip zipped.zip
Two columns with equal width on all devices and viewport (from
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>
Shows globally installed modules
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 class
class 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();
All style attributes can be accessed using the style object of the element. JS
//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
.
If we use several
traits
in the same class, the traits must not have the same method declared
trait 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
Results: 1021