Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Comparison Operators - PHP - P17

  • Dino Cajic
  • 2020-03-03
  • 195
Comparison Operators - PHP - P17
PHP spaceshipPHP spaceship operatorPHP comparison operatorPHP compare operators
  • ok logo

Скачать Comparison Operators - PHP - P17 бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Comparison Operators - PHP - P17 или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Comparison Operators - PHP - P17 бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Comparison Operators - PHP - P17

Comparison operators, or relational operators, test some type of relation between two values. We've seen a few comparison operators in math, such as greater-than and less-than; in PHP, we have a few more comparison operators at our disposal.

The relational operators that we're going to be looking at are:
Greater-than
Greater-than-or-equal-to
Less-than
Less-than-or-equal-to
Equal-to
Identical-to
Not-equal-to
Not-identical-to
Spaceship operator

The comparison operator, whichever one you choose, will evaluate to either true or false. If we say, 3 greater than 2, what we're really saying is:

Is 3 greater than 2?

If we can say YES than that evaluates to a true statement. If we say NO, than that evaluates to a false statement. 

Let's start by assigning a few values to some variables. Remember, single equal sign means assignment; double equal sign means equality.

$a = 10;
$b = 5;
$c = "10";

We'll use the var_dump() function to help us figure out whether the expression will evaluate to true or false; it will just dump the result of the expression. 

Let's start with the equality operator, ==. We want to see whether $a equals $b. Is 10 equal to 5? No, so it's false.

var_dump( $a == $b ); // false

Let's note the different data types for each of our variables.
$a stores an integer
$b stores an integer
$c stores a string

Let's try the equality operator again, this time between $a and $c. It comes out to true? Why? PHP looks at the string "10" and sees that it contains a number inside; it's a numeric string. It loosely compares the two values and sees that they do in fact match. 

The equality operator looks at only the value, not the data type.

var_dump($a == $c); // true

If the data types are important, the identity operator, ===, is used. It compares both the value and the data type. If they don't match, the expression will return false.

var_dump($a === $c); // false

Similarly, if you want to see if the two values are not equal, you can use the "not-equal-to" operator (!=). If the two values are not equal, it returns true. Remember, what we're asking is: is 10 not equal to 5? That's correct, 10 does not equal 5, so that is a true statement.

var_dump($a != $b); // true

The not-equal-to operator tests only the values of the expression, not the data type. To test the data types along with the values, we would use the not-identical-to operator (!==).

var_dump($a != $c); // false
var_dump($a !== $c); // true

Greater-than, less-than, greater-than-or-equal-to, and less-than-or-equal-to are straight forward. I'm sure that you've seen these operators in action at some point in your life.

There is no greater-than-and-identical-to operator or less-than-and-identical-to-operator.
The last operator is called the spaceship operator. It returns 0 when the values are equal, 1 when the right side is greater than the left side, and -1 when the left side is greater than the right side.

0 when equal
1 when right is larger
-1 when left is larger

Although we looked at integer values, we can compare any data type. For example, we can compare $a to the boolean value true. We get a weird result: true. Why? Any integer, except zero, when compared to true, is equal to true. This can cause some issues if you accidentally pass a number into a conditional statement, like the if statement. We'll look at that later.

Read the full article on my website
https://www.dinocajic.com/php-compari...

Code for this tutorial
https://github.com/dinocajic/php-7-yo...

Full Code
https://github.com/dinocajic/php-7-yo...

PHP Playlist
   • PHP Tutorial  

--
Dino Cajic
Author and Head of IT

Homepage: https://www.dinocajic.com
GitHub: https://github.com/dinocajic
Medium:   / dinocajic  
Instagram:   / think.dino  
LinkedIn:   / dinocajic  
Twitter:   / dino_cajic  

My Books
An Illustrative Introduction to Algorithms
https://www.amazon.com/dp/1686863268

Laravel Excel: Using Laravel to Import Data
https://amzn.to/4925ylw

Code Along With Me - PHP: From Basic to Advanced PHP Techniques
https://amzn.to/3M6tlGN

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]