How to Upgrade php 5 to php 7 on Mac
Preface
In mac OS x 10.11, the php version is 5.5. Over the past year, I have seen a lot about php7 and thought php7 has added many new features, I also deleted many old features, so I never wanted to try php7. But today I went to the php official website and carefully checked the new features of php7, it is found that the biggest improvement of php 7 lies in its performance. Although many new features are added in syntax, it does not affect development and is well compatible with the previous php code, here, we will briefly describe the new features of php7. For details, please go to the official website.
Removed features
1. Remove some old extensions and migrate them to PECL (for example, mysql _*)
2. Remove SAPIs support
3.<?
And<? language=“php”
The tag is removed.
4.16 hexadecimal String Conversion is abolished
//PHP5"0x10" == "16" //PHP7"0x10" != "16"
5. HTTP_RAW_POST_DATA is removed (you can use php: // input instead)
6. Static functions no longer support calling a non-static function through an incompatible $ this.
$o = & new className{}
.
7. The php. ini file is removed # used as a comment for unified use; commented out
New Features
- Upgrade ZEND Engine to Zend Engine 3, which is called PHP NG
- Add abstract syntax tree to make compilation more scientific
- 64-bit INT support
- Unified variable syntax
- Original sound TLS-meaningful for extended development
- Improvement of consistent foreach Loop
- Add <=> ,**,?? , \ U {xxxx} Operator
- Added the declaration of the return type.
- Added the declaration of scalar type.
- Core errors can be captured through exceptions.
- Added contextual sensitive lexical analysis
After talking so much nonsense, let's go to the topic.
The upgrade procedure is as follows:
1. Upgrade php (executed on the terminal)
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
After "Syntax OK" appears on the terminal, the installation is successful. At this time, usephpinfo()
Function, you can seePHP Version 7.1.0alpha2
2. Solve the Problem of mysql connection. Because php7 discards mysql extension functions (mysql _ *), all connections to mysql must use pdo, the default path of pdo_mysql.default_socket in php7 is/tmp/mysql. sock, while mysql. the sock path is in/private/var/mysql. sock, so you need to make a soft connection to the tmp folder and execute
cd /tmpsudo ln -s /private/var/mysql/mysql.sock mysql.sock
If the above error is solved, the following prompt will be displayed when php is connected to the database:SQLSTATE[HY000] [2002] No such file or directory
3. Restart apache and mysql!
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.