According to rumors, release 7.1 should take place today. Therefore, I would like to look back a bit and see how php grew out of a set of crutches and props into a full-fledged language for the web. Right in steps, i.e. by version. And in the end I would like a little pozazhigat Think about the role of php in the modern ecosystem.
Let's mentally go back to the days of php4, when wordpress, bitrix and millions of other CMS and home pages were developed.
Php to the fifth version could be called a language with a stretch. Rather, it was a chaotic set of functions that could be quickly called to spit out the data from mysql into the browser. There were the beginnings of the PLO, but such that probably would have been better.
Every second site worked with magic quotes checkboxes turned on. Those. all variables that flowed from the browser were magically screened. Which supposedly allowed them to be safely inserted into the database. In fact, the universal CMS had to clean this business (or leave it as it is, depending on the settings in php.ini). In general, the darkness. But for a beginner, it was supposedly “convenient”: to insert everything that flew into the base and not to steam.
Accordingly, the entry threshold was extremely low, it was enough to learn the mysql_query function and htmlspecialchars. This led to the fact that php sites began to do absolutely everything: almost every second student was a member of the “web studio”.
The threshold was low, the quality of the code matched. Take any major project that began in those days and look at its code. Fear, hate, pain.
But then php5 appeared
. (public, protected, private). (static). . . Reflection API. . __get
__set
. . ArrayAccess ( , ). - . , java, (extends, implements, try, catch ..). .. . .
, type hinting. .. ( ), ( -!).
SPL ( ).
, : , , . , ( php4) , - .
php5 . , php5 — .
5.1 5.2 , : __isset __unset ( __get __set).
type hinting array. .. . , , , .
Serializable.
SPL Reflection
. , json_encode
PDO . mysql_query SQL- .
5.3 .
— ( package java). . composer.
goto
?:
php-fpm
- register_globals. .. - deprecated, 5.4 - . , : ( php) , magic_quotes, . , .
: (traits).
, .. Array(1,2,3)
[1,2,3]
foo()[0]
:
(new foo)->bar()
type hint callable
5.5 "finally".
:
echo [1, 2, 3][0];
echo 'PHP'[0];
::class
.
.(...$params)
c ...
php 6 . challenge UTF ( UTF-16). , . , UTF-8, - . .
, 5.0 5.3. , -.
-, : int, string .. . ,
declare(strict_types=1)
float , int, Fatal Error.
php .
??
<=>
, use, , .
nullable ??string
void
. .. return, fatal error
list
[]
..
[$a, $b] = [$b, $a];
(public
, protected
, private
)
( java)
catch (FirstException | SecondException $e)
"abcdef"[-2]
pcntl_async_signals()
php7.1 : https://secure.php.net/manual/ru/migration71.php
, : (Symfony, Yii .), .. . .. , php, best practices, composer, .
, php- php php4, . - , , . , , .
( "", ), , , .
, php . -?
.. , ( , go - ). ( ), php , C# java. , , . , utf. php — HashMap .. .. java/c#, php, ?
, php, ? , , .
Source: https://habr.com/ru/post/316506/
All Articles