Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
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
3 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
3 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
3 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 ნუგო ყველაშვილი
3 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
3 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
3 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
3 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
3 years ago
0
PHP
LOOPS
0
Comparison between PHP and JS "problem solving" moduls (3) CODE
// Make the array in JS
const array = [0, 1, 2];
array[4] = 4;
console.log(array[3]);
// outputs "undefined"
/* at the third index the array will get the value "undefined" because the value - 4 will be placed at the fourth index and the code will not skip the third index */
// Make the array in PHP
$arr = [0, 1, 2];
$arr[4] = 4;
echo $arr[3];
// unlike JS, that code will not returns anything, there is nothing in 3rd index.
// another interesting fact about it console.log(array.length); // in JS echo (count($arr)); // in PHP // returns 5 in JS and 4 in PHP because in JS the 3rd index got the value - "undefined", but in PHP it just skipped the 3rd index and took the 4th position.
by Luka Khitaridze
3 years ago
0
JavaScript
PHP
Array difference
0
<?php
  // associative array
  $University = [
      "name"=>"TSU",
      "location"=>"Tbilisi",
      "rating"=>"the best",
      "faculty"=>"Social & Political Sciences",
      "degree"=>"PhD"
  ];
  echo 'Georgia has an ancient university '. $University['name'] . ' which is in ' . $University['location'] .'.' . "\n";
  echo 'TSU is ' . $University['rating'] . ' in region' .'.' ."\n";
  echo $University['name'] . ' is my university because I study there at the faculty of ' .  $University['faculty'] .'.' . "\n";
  echo 'my current level of teaching is ' . $University['degree'] .'.' . "\n";

?>
by Mariam Gelkhauri
3 years ago
0
PHP
Array types
Associative array
Object Oriented PHP Tutorial
0
Results: 1578