Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
else-if example for fun CODE
Don't create variables with Georgian alphabet. The following example is just for fun!
$სწავლა_გვინდა = 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დროს ნუ კარგავ!";
}
by Valeri Tandilashvili
3 years ago
2
PHP
If / else
1
➤ Normally, when a function is completed/executed, all of its variables are deleted. However, sometimes we want a local variable NOT to be deleted. We need it for a further job. • To do this, use the
static
keyword when you first declare the variable: For instance:
// function with static variable
function get_num1() {
  static $number1 = 0;
  echo $number1++." ";
}
get_num1();
get_num1();
get_num1(); echo "\n";
// outputs:   0 1 2


// function without static variable
function get_num2() {
	$number2 = 0;
	echo $number2++." ";
}
get_num2();
get_num2();
get_num2();
// outputs:   0 0 0
by Levani Makhareishvili
3 years ago
0
PHP
static
variables
1
➤ The scope of a variable is the part of the script in which the variable can be referenced or used. • A variable declared outside a function has a
global scope
. • A variable declared within a function has a
local scope
, and can only be accessed within that function. For instance:
// global scope
$number = 10;
function print_num() { 
	echo "the number is: $number ";
}
print_num(); // outputs:  Undefined variable $number
// the $number variable has a global scope, and is not accessible within the print_num() function


function task() {
  $name = "Mads"; // local scope
  echo "Variable name inside function is: $name";
  // outputs:  Variable name inside function is: Mads
}
task();
// using $name outside the function will generate an error
echo "Variable name outside function is: $name";
// Undefined variable $name
by Levani Makhareishvili
3 years ago
0
PHP
variables
1
by nikoloz nachkebia
3 years ago
0
PHP
"break" Statement
1
by nikoloz nachkebia
3 years ago
0
PHP
"continue" Statement
0
Date and Time CODE
`
Formats can be:

echo "Today is ". date("Y/m/d") . "\n";
echo "Today is ". date("d/m/Y"). "\n";
echo "Today is ". date("D/M/Y"). "\n";
echo "Today is ". date("d/M/Y"). "\n";
echo "Today is ". date("d.m.Y"). "\n";
echo "Today is ". date("d-m-Y"). "\n";
echo "Today is ". date("l"). "\n";
`
`
Output:
Today is 2022/10/22
Today is 22/10/2022
Today is Sat/Oct/2022
Today is 22/Oct/2022
Today is 22.10.2022
Today is 22-10-2022
Today is Saturday
`
by Gigi Butchvelashvili
3 years ago
0
PHP
0
array_push and print_r functions with arrays.
`
$items = array("me", "you", "he");

array_push($items, "she", "we");

print_r($items);
`
by Gigi Butchvelashvili
3 years ago
0
PHP
array
0
More about array indexes CODE
It's possible to define keys only for some of the array items
$array = [1, 2, "name"=>"Three", 4];
print_r($array);
Result
Array
(
    [0] => 1
    [1] => 2
    [name] => Three
    [2] => 4
)
If we set higher index manually, it will continue adding 1 to the max index
$array = [1, 2, 7=>"Three", 4];
print_r($array);
Result
Array
(
    [0] => 1
    [1] => 2
    [7] => Three
    [8] => 4
)
If we set higher index manually, it will continue adding 1 to the index
$array = [1, 2, 7=>"Three", 4=>"forth", 25];
print_r($array);
Result
Array
(
    [0] => 1
    [1] => 2
    [7] => Three
    [4] => forth
    [8] => 25
)
Only integer and string values are allowed as array keys
$array = [
	1    => "a",
    "1"  => "b",
    "-1"  => "-b",
    '1.5'  => "c",
    true => "d",
];
print_r($array);
Result
Array
(
    [1] => d
    [-1] => -b
    [1.5] => c
)
by Valeri Tandilashvili
3 years ago
2
PHP
Arrays
0
loop array
$fruits =['apple', 'banana', 'mango']; foreach($fruits as $fruit){ echo $fruit. "<br>"; }
by guga muchiashvili
3 years ago
2
PHP
php note
0
== and === operator in PHP ? In PHP == is equal operator and returns
What is the difference between
==
and
===
operator in PHP ? In
PHP
== is equal operator and returns
TRUE
if $a is equal to $b after type juggling and === is Identical operator and return
TRUE
if $a is equal to $b, and they are of the same data type
$a=true ;
 $b=1;
 // Below condition returns true and prints a and b are equal
 if($a==$b){
  echo "a and b are equal";
 }
 else{
  echo "a and b are not equal";
 }
 //Below condition returns false and prints a and b are not equal because $a and $b are of  different data types.
 if($a===$b){
  echo "a and b are equal";
 }
 else{
  echo "a and b are not equal";
 }
by Tinatin Kvinikadze
3 years ago
0
PHP
0
Results: 1578