PHP 8 Crash Course for Beginners - Learn PHP 8 in 1 Hour

PHP 8 Crash Course for Beginners - Learn PHP 8 in 1 Hour

Code With Dary

1 год назад

17,838 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Kamil Wojtalak
Kamil Wojtalak - 15.07.2023 22:59

Ответить
Hamdi Kurdi
Hamdi Kurdi - 11.02.2023 00:22

you are really a great guy I appreciate you but bro we need big projects in php like building systems in php.

Ответить
Didzis Uzuliņš
Didzis Uzuliņš - 03.02.2023 17:26

PHP dev with 20 years experience here. And I'm looking to refresh and improve my knowledge, that's why I watched your video with critical view - what have I missed or what's new in PHP. At switch..case I literally facepalmed and decided to write this comment. Let's start from beginning.
1. echoing single and double quotes the difference is in fact that PHP parses content of double quoted string to search variables while single quoted strings are echoed as they are. Years ago people stated that single quotes execute faster. Theoretically yes, but I have never tested it.
2. It would be great if defining constants you mentioned predefined constants, like PHP_VERSION or magic constants like _FILE_ or __LINE__, just as an example.
3. Illustrating logical operators at if..else statements, a great example would be plain if(true && true){... and if(true && false){... Sure, real world examples are great, but IMHO for beginners it could be easier to understand what's happening under the hood with plain true && false. 🙂
4. The best illustration for identical (===) comparison is. If you don't get it, just try to run it.
<?php
$name = 'Code with Dary';
if (strpos($name, 'PHP') == 0) {
echo "'{$name}' starts with PHP";
}
?>
5. Facepalm at switch..case. Let's rewrite your code to if..elseif statement, to illustrate why I facepalmed.
<?php
if (isset($username) == (strlen($username) < 10)) {
echo 'Username has less than 10 characters';
} elseif(isset($username) == (strlen($username) < 20)) {
// and so on...
}
?>
In switch..case statement PHP always compares expression with case statements as equal (==). Since you have placed less than comparison expressions at case conditions, then PHP compares their result - boolean value against switch expression $username. And since $username is string the closest value to boolean is isset($username). Now I checked PHP documentation and there is example for complex comparisons where true is compared to other comparisons
<?php
switch (true) {
case strlen($username) < 10:
echo "...";
break;
// and so on...
}
?>
Less than comparisons is not the best example for switch..case statement. The goal for explaining it should be illustrating that switch..case always compares with equal expression.
6. At for loop example the "echo $i;" could be confusing for beginners, especially after two examples where you have echoed $i++. You had to emphasize the difference. 🙂
7. I'm glad you didn't mention global keyword at function scope. So many nerves lost refactoring code where someone has used globals. 😀
Overall I would rate this video with 5 out of 10. As you forced me to check some details in PHP documentation, I would recommend you to check it when you will be preparing next tutorial, so you can make it better. 🙂

Ответить
Jana Ramon
Jana Ramon - 03.02.2023 14:09

Php 8 and above have match() instead of switch case ,would have been better if you had included that too.

Ответить
olaide Abiola
olaide Abiola - 02.02.2023 06:32

Thanks for the video, I guess you made a little mistake, parameter is passed at the function definition and arguments are the value passed when function is being called and not the other way round like you said

Ответить
shoyeb khan
shoyeb khan - 01.02.2023 16:32

Nice video, please make video on advanced topics and OOPs in PHP

Ответить
branchyapple
branchyapple - 01.02.2023 15:30

Cool video! nicely edited

Ответить
Hubesh
Hubesh - 01.02.2023 15:04

plz make Ecommerce Project With React js and Laravel API from scratch plz sir plz

Ответить