×
          
              
          
      
      Clear all filters including search bar
          
        Valeri Tandilashvili's Personal Professional Blog
      
    traitstrait 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;
}Trait method who has not been applied, because there are collisions with other trait methods on Galaxygetmypidecho 'Current process ID:' . getmypid();Current process ID:4868index.phpspl_autoload_register(function($class) {
    // echo 'register class:'.$class."<br>";
    require_once("classes/{$class}.php");
});
// echo 'hey there on line 7'."<br>";
$cat = new Cat;
$dog = new Dog;
$tortoise = new Tortoise;
echo $cat->talk();
echo $dog->talk();
echo $tortoise->talk();classes/Talkative.phpinterface Talkative {
    public function talk();
}classes/Cat.phpclass Cat implements Talkative {
    public function talk() {
        return 'Meow' . '<br>';
    }
}classes/Dog.phpclass Dog implements Talkative {
    public function talk() {
        return 'Woof' . '<br>';
    }
}classes/Tortoise.phpclass Tortoise implements Talkative {
    public function talk() {
        return 'Yak yak yak yak ...' . '<br>';
    }
}Filenames and class names must be THE SAMEMakes our code more modular and reusableMakes our code easier to maintainMakes it easier to debug when things go wrongMakes it possible to hide / protect CLASS properties / methods (encapsulation)Makes it possible to use other class properties / methods (inheritance)Makes it possible to use polymorphismnpm list --depth 0npm list --depth 1lastNameletwindowundefined// Declaring variable using keyword "var"
var firstName = "Jet"
// Declaring variable using keyword "let"
let lastName = "Li"
// Declaring variable without using any keyword
carMark = "Tesla"
function driveCar() {
  console.log(this.firstName + ' ' + this.lastName + ' is driving a car '+this.carMark)
}
driveCar()Jet undefined is driving a car TeslavarwindowwindowfirstNamelastNamewindow.firstName;  // "Jet"
window.lastName;  // undefined
window.carMark;  // "Tesla"var el = document.getElementById("myimg");
el.src = "https://www.sololearn.com/Images/home-new/1073.png";<img id="myimg" src="https://www.sololearn.com/Images/home-new/1068.png" alt="" />attributesJavaScript// Anonymous function
document.addEventListener('click', function(){
  console.log('You clicked me!');
})// Arrow function
document.addEventListener('click', () => {
  console.log('You clicked me!');
})// More minimalistic arrow function 
document.addEventListener('click', () => console.log('You clicked me!'))CROSS JOININNERimplicitSELECT 
    students.*,
    notes.*
FROM `notes`
CROSS JOIN `students` JOINSELECT 
    students.*,
    notes.*
FROM `notes`
JOIN `students` JOININNER JOINSELECT 
    students.*,
    notes.*
FROM `notes`
INNER JOIN `students` ImplicitSELECT 
    students.*,
    notes.*
FROM `notes`, `students` register_shutdown_function('myexit');
function myexit()
{
	echo "</schedule>";
}