×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
getmypid
- Gets PHP's process IDecho 'Current process ID:' . getmypid();
The output will be:Current process ID:4868
index.php
filespl_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();
Content of classes/Talkative.php
file interface Talkative {
public function talk();
}
Content of classes/Cat.php
file class Cat implements Talkative {
public function talk() {
return 'Meow' . '<br>';
}
}
Content of classes/Dog.php
file class Dog implements Talkative {
public function talk() {
return 'Woof' . '<br>';
}
}
Content of classes/Tortoise.php
file class Tortoise implements Talkative {
public function talk() {
return 'Yak yak yak yak ...' . '<br>';
}
}
Filenames and class names must be THE SAME
Makes our code more modular and reusable
Makes our code easier to maintain
Makes it easier to debug when things go wrong
Makes it possible to hide / protect CLASS properties / methods (encapsulation)
Makes it possible to use other class properties / methods (inheritance)
Makes it possible to use polymorphism
npm list --depth 0
Shows all packages with only their dependencies (one level deep)npm list --depth 1
lastName
declared by the keyword let
is not added to the global window
object.
That is why the variable is equal to undefined
// 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()
The result will be:Jet undefined is driving a car Tesla
Because declaring variable with var
keyword and without any declaration keyword are the same.
Both add the variable to the global window
object.
After running the above code, global object window
will have firstName
and lastName
attributeswindow.firstName; // "Jet"
window.lastName; // undefined
window.carMark; // "Tesla"
var el = document.getElementById("myimg");
el.src = "https://www.sololearn.com/Images/home-new/1073.png";
HTML<img id="myimg" src="https://www.sololearn.com/Images/home-new/1068.png" alt="" />
Note: Practically all attributes
of an element can be changed using JavaScript
// Anonymous function
document.addEventListener('click', function(){
console.log('You clicked me!');
})
The same function with arrow function syntax// Arrow function
document.addEventListener('click', () => {
console.log('You clicked me!');
})
Even more minimalistic arrow function// More minimalistic arrow function
document.addEventListener('click', () => console.log('You clicked me!'))
CROSS JOIN
is the same as INNER
or implicit
joins.
Without conditions, both result in Cartesian product:SELECT
students.*,
notes.*
FROM `notes`
CROSS JOIN `students`
JOIN
example:SELECT
students.*,
notes.*
FROM `notes`
JOIN `students`
JOIN
is the short form of INNER JOIN
SELECT
students.*,
notes.*
FROM `notes`
INNER JOIN `students`
Implicit
join exampleSELECT
students.*,
notes.*
FROM `notes`, `students`
Both the queries return the exact same resultregister_shutdown_function('myexit');
function myexit()
{
echo "</schedule>";
}
empty
and isset
$var = 0;
// Evaluates to true because $var is empty
if (empty($var)) {
echo '$var is either 0, empty, or not set at all';
}
// Evaluates as true because $var is set
if (isset($var)) {
echo '$var is set even though it is empty';
}
The following values are considered to be false:
""
(an empty string)
0
(0 as an integer)
0.0
(0 as a float)
"0"
(0 as a string)
NULL
FALSE
array()
(an empty array)