Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for PHP variables: A variable starts with the $ sign, followed by the name of the variable A variable name must start with a letter or the underscore character A variable name cannot start with a number A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) Variable names are case-sensitive ($age and $AGE are two different variables) Remember that PHP variable names are case-sensitive!
`
by Tinatin Kvinikadze
2 years ago
0
PHP
variables
0
PHP has a total of eight data types that we use to construct our variables: Integers: are whole numbers, without a decimal point, like 4195. Doubles: are floating-point numbers, like 3.14159 or 49.1. Booleans: have only two possible values either true or false. NULL: is a special type that only has one value: NULL. Strings: are sequences of characters, like 'PHP supports string operations.' Arrays: are named and indexed collections of other values. Objects: are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class. Resources: are special variables that hold references to resources external to PHP (such as database connections).
by Tinatin Kvinikadze
2 years ago
0
PHP
data types
variables
0
In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive. In the example below, all three echo statements below are equal and legal:
<!DOCTYPE html>
<html>
<body>

<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>

</body>
</html>
Note: However; all variable names are case-sensitive!
by Tinatin Kvinikadze
2 years ago
0
PHP
Case Sensitivity
0
User Defined Function in PHP
A user-defined function declaration starts with the key-word
function
:
function FUNCTIONNAME() {
  code to be executed;
}
by Eka Suarishvili
2 years ago
0
PHP
0
Variable scope
A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function. A variable declared within a function has a LOCAL SCOPE and can only be accessed within that function:
<?php
$name='GURAM';//Global variable
function local_var() {
    $name='guram'; //local variable
    echo  'Local variable: '.$name ."\n";
  }
local_var();
echo 'Global variable: '.$name;
?>
"static" 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:
<?php
function myTest() {
  static $x = 0;
  echo $x;
  $x++;
}

myTest();
myTest();
myTest();
?>
by Guram Azarashvili
2 years ago
0
PHP
0
Array
<!DOCTYPE html>
<html>
<body>

<?php

$students_inf = array(
array(
	
        "Name" => 'Luka', 
	"Age" => 21,
	"E-mail" => 'Luka.N111@gmail.com',
	"Status" => 'Registered'

  ),    
	
     array(
	"Name" => 'Nini',	
	"Age" => 20,
	"E-mail" => 'Nini.K312@gmail.com',
	"Status" => 'Unregistered'
		
  ),
		
     array(
   	"Name" => 'Giorgi',
        "Age" => 22,
        "E-mail" => 'Giorgi.ES8@gmail.com',     
   	"Status" => "Registered"
   	
   	)
 );
  
 //You can get students information with echo and var_dump. 
 
 var_dump(json_encode($students_inf));
 
 echo str_repeat("<br />",5);
 
 
 echo $students_inf[0]['Name']. "<br />";
 echo $students_inf[0]['Age']. "<br />";
 echo $students_inf[1]['Status']. "<br />";  
 echo $students_inf[2]['E-mail']. "<br />"; 

  
 ?>

</body>
</html>
by ნუგო ყველაშვილი
2 years ago
0
PHP
array
php
0
strict requirement
PHP automatically associates a data type to the variable, depending on its value. Since the data types are not set in a strict sense, you can do things like adding a string to an integer without causing an error. In PHP 7, type declarations were added. This gives us an option to specify the expected data type when declaring a function, and by adding the strict declaration, it will throw a "Fatal Error" if the data type mismatches.
<?php declare(strict_types=1); // strict requirement

function addNumbers(int $a, int $b) {
  return $a + $b;
}
echo addNumbers(5, "5 days");
// since strict is enabled and "5 days" is not an integer, an error will be thrown
?>
by Guram Azarashvili
2 years ago
0
PHP
PHP official doc
0
const a = 10 + '20';                 // the sum of integer and string values
const b = '20' + '20';                   // the sum of two string values
console.log(a, b);                       // returns "1020" , "2020" 
console.log(typeof(a, b));          // both are strings
$a = 10 + '20';                          // The sum of an integer and a string
$b = '1020' + '20';                        // The sum two strings
echo $a, "\n ", $b, "<br>";         // returns 30, 1040 
echo var_dump($a, $b);            // both are integers (int+str) (str+str)
/* When you try to perform math operations with strings in PHP, they are cast to approprite type. In this case to int. But you can cast integer back to string in the below example */
$integer = 10;
$stringIncrement = '20';
$result = $integer + $stringIncrement;
$result = (string) $result;
var_dump($result);
by Luka Khitaridze
2 years ago
0
JavaScript
PHP
Integer
String
0
switch operator
$age = 9; switch($age){ case $age < 12: echo 'u are child'; break; case $age > 12 && $age <19: echo 'u are teen'; break; case $age > 20: echo 'u are an adult'; break; }
by guga muchiashvili
2 years ago
0
PHP
php note
0
/* The main difference between both loops is that while loop checks the condition at the beginning, whereas do-while loop checks the condition at the end of the loop */
// make the while loop example
$i = 1;
while ($i < 5) {
    echo "the result is $i", "\n";
    $i++;
    }
// please note, If the condition never becomes false, the statement will continue to execute indefinitely.
// make the do...while loop
$i = 1;
do {
echo "hello world";
}
while ($i < 0);
// is that case will return the result?
/* Note that in a do while loop, the condition is tested AFTER executing the statements within the loop. This means that the do while loop would execute its statements AT LEAST ONCE, EVEN IF THE CONDITION IS FALSE the first time */ // Therefore it returns "hello world" only one time
by Luka Khitaridze
2 years ago
0
PHP
LOOPS
0
Results: 1580