×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
frameborder="0"
gives zero width border to <iframe>
<caption>
goes inside <thead>
and is title of the table. The title is centered horizontally. caption
is above the first tr
<table>
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</table>
1
Possible values for the attribute are: 1
, A
, a
, I
, i
source
code4123
new code line
one more line1h$variable = 1;
JS alternative
let variable = 1;
PHP - check if the variable exists
if (isset($variable))
JS alternative
if (typeof variable !== "undefined")
PHP count array elements
$count = count([2, 3, 4]);
JS alternative
let count = [2, 3, 4].length;
PHP count letters in the string
$len = strlen('some string');
JS alternative
let len = 'some string'.length;
PHP absolute value of a given number
$variable = abs(-5);
JS alternative
let variable = Math.abs(-5);
PHP - power of a number
$square = pow(5, 2);
JS alternative
let square = Math.pow(5, 2);
PHP - square root of a number
$square_root = sqrt(16);
JS alternative
let square_root = Math.sqrt(16);
PHP - minimum number
$max = min(2, 3, 4);
JS alternative
let max = Math.min(2, 3, 4);
PHP - maximum number
$max = max([2, 3, 4]);
JS alternative
let max Math.max(...[2, 3, 4])
PHP calculates sum of the array elements
$sum = array_sum([2, 3, 4]);
JS alternative
let sum = 0;
let arr = [1, 2, 3];
for (let value of arr) {
sum += value;
}
Another way to calculate the same
let arr = [1, 2, 3];
let sum = 0;
let len = arr.length;
for (let i = 0; i < len; sum += arr[i++]);
PHP - string position
$pos = strpos('Hello world', 'world');
JS alternative
let pos = 'Hello world'.indexOf('world');
PHP - edit letter in a string
$string[4] = 'X';
JS alternative
string = string.substring(0, 4) + 'X' + string.substring(5);
PHP convert the variable to integer
$variable = intval(5.5);
JS alternative
let variable = parseInt(5.5);
PHP - explode the sentence
$sentence = "Lorem ipsum dolor st amet";
$words = explode(" ", $sentence);
JS alternative
let sentence = "Lorem ipsum dolor st amet";
let words = sentence.split(" ");
$სწავლა_გვინდა = true;
$ვაბარებთ_უნივერსიტეტში = true;
$სწავლა_ძვირია = true;
$მუშაობა_გვინდა = false;
if ($სწავლა_გვინდა) {
if ($ვაბარებთ_უნივერსიტეტში) {
if ($სწავლა_ძვირია) {
echo "\nუნივერსიტეტი ძვირია, ვიწყებთ სწავლას applications.ge-ს კურსზე!";
} else {
echo "\nვსწავლობთ უნივერსიტეტში!";
}
} else {
echo "\nვიწყებთ სწავლას applications.ge-ს კურსზე!";
}
} elseif ($მუშაობა_გვინდა) {
echo "\nვმუშაობთ";
} else {
echo "\nდროს ნუ კარგავ!";
}
continue
statement breaks only one iteration in the loop and continues with the next iterationfor ($x = 0; $x < 10; $x++) {
if ($x == 7) {
continue;
}
echo "$x"."\n";
}
echo "\n\n";
Prints Only numbers evenly divisible by 2
for ($x = 0; $x < 10; $x++) {
if ($x%2 == 1) {
continue;
}
echo "Example2: $x"."\n";
}
break
statement is used to jump out of loops
for ($x = 0; $x < 10; $x++) {
if ($x == 7) {
break;
}
echo "$x"."\n";
}
Another example using break
statement
In this example prints numbers less than 6
for ($x = 0; $x < 10; $x++) {
if ($x*$x > 30) {
break;
}
echo "$x"."\n";
}
Uses break
statement instead of for loop condition section
for ($i = 0; ; $i ++) {
if ($i == 10) {
break;
}
echo $i . "\n";
}
and
($x and $y)
True if both $x and $y are true
$x = 40;
$y = 50;
if ($x > 30 and $y > 45) {
echo "True";
}
or
($x or $y)
True if either $x or $y is true
$x = 40;
$y = 50;
if ($x > 30 or $y == 85) {
echo "True";
}
xor
($x xor $y)
True if either $x or $y is true, but not both
$x = 40;
$y = 50;
if ($x > 30 xor $y == 85) {
echo "True";
}
&&
($x && $y)
True if both $x and $y are true
$x = 40;
$y = 50;
if ($x > 30 and $y > 45) {
echo "True";
}
||
($x || $y)
True if either $x or $y is true
$x = 40;
$y = 50;
if ($x > 30 or $y == 85) {
echo "True";
}
!
(!$x)
True if $x is not true
$x = 40;
if ($x !== 50) {
echo "True";
}
==
(Equal)
Returns true if $x is equal to $y
$x = 40;
$y = "40";
var_dump($x == $y); // true
===
(Identical)
Returns true if $x is equal to $y, and they are of the same type
$x = 40;
$y = "40";
var_dump($x === $y); // false
!=
(Not equal)
Returns true if $x is not equal to $y
$x = 40;
$y = "40";
var_dump($x != $y); // false
<>
(Not equal)
Returns true if $x is not equal to $y
$x = 40;
$y = "40";
var_dump($x <> $y); // false
!==
(Not identical)
Returns true if $x is not equal to $y, or they are not of the same type
$x = 40;
$y = "40";
var_dump($x !== $y); // true
>
(Greater than)
Returns true if $x is greater than $y
$x = 40;
$y = 50;
var_dump($x > $y); // false
<
(Less than)
Returns true if $x is less than $y
$x = 40;
$y = 50;
var_dump($x < $y); // true
>=
(Greater than or equal to)
Returns true if $x is greater than or equal to $y
$x = 40;
$y = 50;
var_dump($x >= $y); // false
<=
(Less than or equal to)
Returns true if $x is less than or equal to $y
$x = 40;
$y = 50;
var_dump($x <= $y); // true