Objective
In Mac OS X 10.11 PHP version is 5.5, recently more than a year, see a lot about PHP7 introduction, think Php7 added a lot of new features, also deleted the original many old features, so has not wanted to try to use PHP7, But today to the PHP official online serious look at the new features of the PHP7, found that in fact, php7 the biggest increase in performance, although the syntax adds a lot of new features, but does not affect the development, and can be very good compatibility with the previous PHP code, here briefly explain the PHP7 of the new features, Please go to the official website to see the specific instructions.
Some of the features removed
1. Removed some old extensions, moved to PECL (ex: mysql_*)
2. Removal of Sapis support
3. <?
and <? language=“php”
Such a label was removed
4.16 binary string conversion was abolished
?
12345 |
//PHP5 "0x10" == "16" //PHP7 "0x10" != "16" |
5.http_raw_post_data removed (can be replaced with php://input)
6. Static functions are no longer supported to invoke a non-static function through an incompatible $this.
$o = & new className{}
, and no longer support such a notation
7.php.ini file removed # as a comment, unified with; go to comment
New features
- Zend Engine upgrade to Zend 3, known as PHP NG
- Add abstract syntax trees to make compilation more scientific
- 64-bit INT support
- Unified variable Syntax
- TLS for OST-meaning for extended development
- Improvements to the consistency foreach loop
- Added <=>, * * 、?? , \u{xxxx} operator
- Added declaration of return type
- Added a scalar type of declaration
- The core error can be caught by an exception
- Added context-sensitive lexical analysis
Say so much nonsense, go to the subject.
The upgrade steps are as follows:
1. Upgrade PHP (execute under Terminal)
?
1 |
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 |
The installation is successful until "Syntax OK" appears in the terminal. This time, with the phpinfo()
function, you can seePHP Version 7.1.0alpha2
2, solve the problem of MySQL link, because PHP7 abandoned the MySQL extension function (mysql_*), all link MySQL to use PDO, and PHP7 pdo_mysql.default_socket default path is/tmp/ Mysql.sock, and Mysql.sock path in/private/var/mysql/mysql.sock, so need to do a soft connect to TMP folder, execute under Terminal
?
12 |
cd /tmp sudo ln -s /private/var/mysql/mysql.sock mysql.sock |
If you resolve the above error, the PHP link database will prompt you:SQLSTATE[HY000] [2002] No such file or directory
3, restart Apache and MySQL, so you can!
Summarize
The above is the entire content of this article, I hope that the content of this article on everyone's study or work can bring certain help, if there are questions you can message exchange, thank you for the script home support.
Instructions for upgrading PHP 5 to PHP 7 under Mac