Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
by დავით ქუთათელაძე
3 years ago
0
PHP
variable types
1
$empty_Array = []; // returns false, in JS it returns true $test0 = 0; // returns false $test1 = 1; // returns true $string_Zero = '0'; // returns false, in JS it returns true $quotes = ' '; // returns false $null = null; // returns false
if (0) {                            // false same as empty, true same as 1
	echo "true";
} else {
	echo "false";
}
// therefore condition returns false :)
by Luka Khitaridze
3 years ago
0
PHP
JS
PHP
0
PHP Constants
Constants are similar to variables except that they cannot be changed or undefined after they've been defined. Begin the name of your constant with a letter or an underscore. To create a constant, use the define() function:
define(name, value, case-insensitive)
Parameters: name: Specifies the name of the constant; value: Specifies the value of the constant; case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false; The example below creates a constant with a case-sensitive name:
<?php
  define("georgian_player", "Kvicha Kvaratskhelia");
  echo georgian_player;
  // Outputs "Kvicha Kvaratskhelia"
?>
The example below creates a constant with a case-insensitive name:
<?php
  define("georgian_player", "Kvicha Kvaratskhelia", true);
  echo Georgian_Player;
  // Outputs "Kvicha Kvaratskhelia"
?>
No dollar sign ($) is necessary before the constant name.
by Tornike Kartvelishvili
3 years ago
0
PHP
Variables
0
➤ The if...else statement executes some code if a condition is true and another code if that condition is false. For instance:
$x = 10;
if ($x > (2+4)) {
	echo "Condition is True !\n";
} else {
	echo "Condition is False !\n";
} // outputs: Condition is True !


if ($x < (2+4)) {
	echo "Condition is True !\n";
} else {
	echo "Condition is False !\n";
} // outputs: Condition is False !


$my_age = 19;
if ($my_age >= 18 ) {
	echo "I am adult!";
} else {
	echo "I am child!";
} // outputs: I am adult!
by Levani Makhareishvili
3 years ago
0
PHP
If...else statement
1
PHP The static Keyword
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(); // output  is 1
myTest(); // output  is 2
myTest(); // output is 3
?>
Then, each time the function is called, that variable will still have the information it contained from the last time the function was called. Note: The variable is still local to the function.
by Tornike Kartvelishvili
3 years ago
0
PHP
Variables
Variables Scope
0
by nikoloz nachkebia
3 years ago
0
PHP
echo statement
1
➤ The if statement is used to execute a block of code only if the specified condition evaluates to true. For instance:
$name = "Levani";
if ( $name == "Levani") {
	echo "Condition is True !\n";
}

// "l" A full textual representation of the day of the week
if (date("l") == "Monday") {
	echo "Let's start coding !\n";
}

$x = 10;
$y = 5;
if ($x > $y) {
	echo "10 > 5\n";
}

if ($x < 2) {
	// conditions is false
}
by Levani Makhareishvili
3 years ago
0
PHP
If statement
1
by nikoloz nachkebia
3 years ago
0
PHP
PHP Comments
1
PHP $GLOBALS[index] array
HP also stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. This array is also accessible from within functions and can be used to update global variables directly.
<?php
  $x = 70;
  $y = 7;

  function myNum {
    $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
  }
  
  myNum();
  echo $y; // output is 77
?>
by Tornike Kartvelishvili
3 years ago
0
PHP
Variables
Variables Scope
0
PHP The global Keyword
The global keyword is used to access a global variable from within a function. To do this, use the global keyword before the variables (inside the function):
<?php
  $x = 70;
  $y = 7;

  function myNum {
    global $x, $y;
    $y = $x + $y;
  }
  
  myNum();
  echo $y; // output is 77
?>
by Tornike Kartvelishvili
3 years ago
0
PHP
Variables
Variables Scope
0
Results: 1578