PHP Operator Precedence and Associativity - PHP Tutorial 37

preview_player
Показать описание
Notes for You:: PHP Operator Precedence and Associativity - PHP Tutorial 37

Precedence:
- determines while evaluating any expression; which operator should be evaluated first before the other? I.e. which operator needs to be given higher precedence than the other?

Associativity:
- determines if same operator appears one or more times in an expression, in which direction the specific operator need to be evaluated

$a = 3 * 5 + 4 / 2 + 3 + 20 -10

Note: Operators with equal precedence and non-associative should not be used next to each other. Ex: 1 < 2 > 3

Example code:
$a = 2 + 2 + 2;
echo $a,"<br/>"; // 6

$b = 2 + 3 * 5;
echo $b,"<br/>"; // 17

$c = 3 * 5 + 4 / 2 + 3; // 20
echo $c,"<br/>";

$d = 3 * (5 +4 ) / 2 +3; // 16.5
echo $d,"<br/>";

$e = 3 * 5 + 4 / 2 + 3 + 20 -10; // 30
echo $e,"<br/>";

$f = "Score: " . 2 + 2; // 2
echo $f,"<br/>";

$g = "Score: " . (2 + 2); // Score: 4
echo $g,"<br/>";

$h = 2 + 2 . "Score: "; // 4Score:
echo $h,"<br/>";

Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.

=========================================

Follow the link for next video:
PHP Tutorial 38 - Control Statements in PHP | PHP Control Structures

Follow the link for previous video:
PHP Tutorial 36 - Special Operators in PHP | PHP Special Operators Tutorial

=========================================

PHP Tutorials Playlist:-

=========================================
Watch My Other Useful Tutorials:-

MySQL Tutorials Playlist:-

HTML Tutorials Playlist:-

CSS Tutorials Playlist:-

JavaScript Tutorials Playlist:-

=========================================

► Subscribe to our YouTube channel:

► Visit our Website:

=========================================
Hash Tags:-
#ChidresTechTutorials #PHP #PHPTutorial
Рекомендации по теме
Комментарии
Автор

SUBSCRIBE, SHARE & SUPPORT:
VISIT & LEARN AT FREE OF COST:

ChidresTechTutorials
Автор

Very good teacher. I have a request: I would like to join your channel for special content rather than another website such as Freecode and so on. But I really want to focus on one subject each time, is that possible? I am asking because PHP and MySQL are not finished. Hope you can understand my request and not misunderstanding it.

loscolaro