Linux – PHP 7.0 and MSSQL (Microsoft SQL)

Microsoft has PHP Linux Drivers for SQL Server for PHP 7 and above on PECL. These are production ready. To download them, follow these steps: Ubuntu 16.04: sudo su curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add – curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list exit sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql mssql-tools unixodbc-dev sudo pecl install sqlsrv … Read more

C#’s null coalescing operator (??) in PHP

PHP 7 adds the null coalescing operator: // Fetches the value of $_GET[‘user’] and returns ‘nobody’ // if it does not exist. $username = $_GET[‘user’] ?? ‘nobody’; // This is equivalent to: $username = isset($_GET[‘user’]) ? $_GET[‘user’] : ‘nobody’; You could also look at short way of writing PHP’s ternary operator ?: (PHP >=5.3 only) … Read more

How to install php extension using pecl for specific php version, when several php versions installed in system?

Here’s what worked best for me when trying to script this (in case anyone else comes across this like I did): $ pecl -d php_suffix=5.6 install <package> $ pecl uninstall -r <package> $ pecl -d php_suffix=7.0 install <package> $ pecl uninstall -r <package> $ pecl -d php_suffix=7.1 install <package> $ pecl uninstall -r <package> The … Read more

Void as return type

Edit: A new separate RFC for a void return type has been published, has passed the vote, and was implemented in PHP 7.1. There is now a void return type in PHP. 🙂 Original Post: Taken from wiki.php.net: Future Work Ideas for future work which are out of the scope of this RFC include: Allow … Read more

PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting

You installed PHP IntelliSense extension, and this error because of it. So if you want to fix this problem go to this menu: File -> Preferences -> Settings Now you can see 2 window. In the right window add below codes: { “php.validate.executablePath”: “C:\\wamp64\\bin\\php\\php7.0.4\\php.exe”, “php.executablePath”: “C:\\wamp64\\bin\\php\\php7.0.4\\php.exe” } Just like below image. NOTICE: This address C:\\wamp64\\bin\\php\\php7.0.4\\php.exe … Read more

PHP 7 and strict “resource” types

PHP does not have a type hint for resources because No type hint for resources is added, as this would prevent moving from resources to objects for existing extensions, which some have already done (e.g. GMP). However, you can use is_resource() within the function/method body to verify the passed argument and handle it as needed. … Read more

“Call to undefined function mysql_connect()” after upgrade to php-7 [duplicate]

From the PHP Manual: Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide. Alternatives to this function include: mysqli_connect() PDO::__construct() use MySQLi or PDO <?php $con = mysqli_connect(‘localhost’, ‘username’, ‘password’, ‘database’);