Python and PHP: Main Syntax Differences

preview_player
Показать описание
If you're jumping to Python from PHP, like myself, let me give you a summary of syntax differences.

-----

Рекомендации по теме
Комментарии
Автор

A good book that helped me to switch from PHP to Python: "From PHP to Python: a Straight-to-the-Point Guide"
Really dense and easy to follow

mikepinge
Автор

3:48 In PHP, Logical Operators can be in English words too

if ($x or $y) return $x;

wildfoster
Автор

Another big difference: array from PHP are list, dict or set. The list has no key [1, 2, 3]. The dict has key and value {'a': 1, 'b': 2, 'c': 3}. The set has only unique keys {'a', 'b', 'c'} ({'a', 'a', 'c'} is impossible). There is no need for a broken array_is_list function in Python.

LostLans
Автор

3:32 In PHP, comments can be in this format:

# comments here

In PHP, If statements doesn't require braces:

if ($x < 2):
echo 'hello';
elseif:
echo 'something else';
endif;

wildfoster
Автор

Php is better than python and JavaScript when it comes to types and OO class features. The class/interface features are one of the best if not the best of any similar language (dynamic language). Php is also faster than python and ruby. Php has better features for designing a class based OO system from scratch.

ojsojs
Автор

Python looks stupid, i didn't like it

blackview
visit shbcf.ru