×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
0
. Negative numbers are also accepted.main-column {
flex: 3;
order: 2;
}
.sidebar-one {
flex: 1;
order: 1;
}
composer.lock
composer update
1. The composer.lock file will be ignored
2. composer.json
file dependencies will be installed and updated (if a dependency is not installed it will be downloaded)#nav li {
list-style: none;
float: left;
padding: 0 15px 0 0;
}
$this
inside static methodsclass Greeting {
public $nonStatic = 'some value';
public static function hello() {
return $this->nonStatic;
}
}
// echo Greeting::hello();
$obj1 = new Greeting();
echo $obj1->hello();
After executing the above code, following error will be generated:Fatal error: Uncaught Error: Using $this when not in object context
$this
inside static methodsclass Circle {
public static $pi = 3.1415926535;
public $radius;
public function __construct($radius) {
$this->radius = $radius;
}
public function getArea() {
return pow($this->radius, 2) * self::$pi;
}
public function getPerimeter() {
return $this->radius * 2 * self::$pi;
}
}
$circle1 = new Circle(5);
echo "\nArea: " . $circle1->getArea();
echo "\nPerimeter: " . $circle1->getPerimeter();
personal_id
after api_method
column in requests
table ALTER TABLE requests
ADD COLUMN personal_id VARCHAR(15) AFTER api_method;
If we run the same alter
statement one more time, we will get the following error with code 1060
Error Code: 1060. Duplicate column name 'personal_id'
If we want to delete a column from a table, we use the following commandALTER TABLE `requests`
DROP COLUMN `status_id`;
function foo()
{
static $numOfCalls = 0;
$numOfCalls++;
echo "this function has been executed " . $numOfCalls . " times" . PHP_EOL;
}
foo();
foo();
foo();
After executing the ebove code, $numOfCalls
static variable gets incremented and the following text is printed:this function has been executed 1 times
this function has been executed 2 times
this function has been executed 3 times
constant can not be changed
static variable can not be accessed with the class object
dollar sign is needed to access static variable inside and outside of the class
constant name can not be a keyword, e.g. class (BUT: function, self, parent, static)
Similarities :
both of them are class members
both of them are accessible with "self" keyword inside the class
class Goodbye {
const LEAVING_MESSAGE = "Thank you for visiting US!\n";
public function byebye() {
echo self::LEAVING_MESSAGE;
}
}
$goodbye = new Goodbye();
// Access const variable with getter method
$goodbye->byebye();
// Access const variable with class name
echo Goodbye::LEAVING_MESSAGE;
// Access const variable directly with object
echo $goodbye::LEAVING_MESSAGE;
About class constants:
Constants cannot be changed once it is declared
Class constants are case-sensitive
A class constant is declared inside a class with the const keyword
It is recommended to name the constants in all uppercase letters
__destruct
method will be executed at the end (before the script stops execution)class Bill {
public $dinner = 20;
public $dessert = 5;
public $drink = 3;
public $bill = 0;
public function __construct() {
$this->bill = 10;
}
public function dinner($count) {
$this->bill += $count * $this->dinner;
return $this;
}
public function dessert($count) {
$this->bill += $count * $this->dessert;
return $this;
}
public function drink($count) {
$this->bill += $count * $this->drink;
return $this;
}
public function __destruct() {
echo $this->bill;
}
}
$bill = new Bill;
$bill->dinner(3)->dessert(2)->drink(1);