php-7

Mysql error : mysqli_connect(): (HY000/2002): Connection refused

若如初见. 提交于 2019-12-12 23:03:27
问题 I have install mysql on digital ocean and trying to connect through php script and I got this error mysqli_connect(): (HY000/2002): Connection refused in /var/www/waev.in/signup/ajax/send_code.php on line 9 Failed to connect to MySQL: Connection refused What can be the issue : my php script <?php include '../func/sms_function.php'; $mysql_host='{ip}'; $mysql_user='root'; $mysql_pass='********'; $my_db='wesearch_waev_user'; $con = mysqli_connect($mysql_host,$mysql_user,$mysql_pass); if (mysqli

Which is faster between (string)$value and “$value” when casting to a string

放肆的年华 提交于 2019-12-12 20:17:33
问题 In PHP, assuming $value = 12345; (an integer), which is faster when casting $value from an integer to a string; $value = (string)$value; or $value = "$value"; This is a kind of performance measure question and specifically for this case. Thanks for your help! 回答1: Your question is really about the efficacy of the php interpreter, and how it converts php code (the one you write) to php bytecode (the one that runs and may actually consume time and resources). If i take p01ymath's experiment,

PHP IntlDateFormatter wrong date/time conversion

女生的网名这么多〃 提交于 2019-12-12 19:38:47
问题 I recently stumbled on a problem with PHP v7.0.4. when trying to format some dates in the past. I work on a project, in which there is a thing called "empty date", basically a "1800-01-01" (used instead of the NULL value). I'm using GMT+1, "Europe/Berlin". In process of handling it, and with the Date localization involved, the IntlDateFormatter started making some issues and I chased them down to having exceptions if the dates are <= 1893-04-01 (an early April fool thing?). You can see some

PHP: Split a string by comma(,) but ignoring anything inside square brackets?

自作多情 提交于 2019-12-12 19:04:22
问题 How do I split a string by , but skip the one that's inside an array String - "'==', ['abc', 'xyz'], 1" When I do explode(',', $expression) it's giving me 4 item in array array:4 [ 0 => "'=='" 1 => "['abc'" 2 => "'xyz']" 3 => 1 ] But I want my output to be - array:3 [ 0 => "'=='" 1 => "['abc', 'xyz']" 2 => 1 ] 回答1: yeah, regex - select all commas, ignore in square brakets /[,]+(?![^\[]*\])/g https://regexr.com/3qudi 回答2: For your example data you might use preg_split and use a regex to match

Laravel 5.5: PHPUnit (with coverage) doesn't like routes from multiple files and throws “A facade root has not been set”. Without coverage it's green

喜欢而已 提交于 2019-12-12 15:14:28
问题 I have Laravel 5.5 where I decided to group routes in files to organise them in a more meaningful way. Here's a simplified example - the web route files live in: app/Http/Routes/Web/static.php app/Http/Routes/Web/test.php static.php contains: <?php declare(strict_types=1); namespace Foo\Http\Routes\Web; use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('welcome'); }); test.php contains: <?php declare(strict_types=1); namespace Foo\Http\Routes\Web; use Illuminate

After Upgrading to PHP Version 7 i get XAMPP Apache Server Error

独自空忆成欢 提交于 2019-12-12 14:40:55
问题 I have latest Xampp installed and i want to upgrade PHP version to PHP 7. so i downloaded PHP 7 from.. http://windows.php.net/download#php-7.0 VC14 x86 Thread Safe Zip file After downloading i extracted zip to custom file and replace full php file and folder to xampp/php with new php file for php 7 i changed xamp\apache\conf\extra\httpd-xampp.conf so my new httpd-xampp.conf is LoadFile "E:/xamp/php/php7ts.dll" LoadFile "E:/xamp/php/libpq.dll" LoadModule php7_module "E:/xamp/php/php7apache2_4

Changed behavior of (un)serialize()?

给你一囗甜甜゛ 提交于 2019-12-12 13:07:00
问题 EDIT: Problem is a documented php bug by now: https://bugs.php.net/bug.php?id=71617 thanks to for finding that one @Danack I'm just migrating an application from PHPH 5.5 to PHP 7 and stumbled over some strange behavior when it comes to serializing objects. I have tried to cook it down to a minimal, complete and verifiable example which can be found at http://sandbox.onlinephpfunctions.com/code/e926a7398119ea715531cafe4ce6a22c329e53b8 The problem is that if a class extends ArrayObject then

Composer does not detect php7 instead it uses 5.6. How can I set the CLI to use php7

南笙酒味 提交于 2019-12-12 12:24:10
问题 Here when I execute php -v , it says it has php7 but when I try to execute composer update the response it Your requirements could not be resolved to an installable set of packages. Problem 1 - This package requires php >=7.0.0 but your PHP version (5.6.33) does not satisfy that requirement. How can I fix this? NOTE : I'm not allowed to uninstall previous version of php Here is the composer.json { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework",

Why doesn't PHP's null coalescing operator (??) work on class constants with different visibilities?

自作多情 提交于 2019-12-12 12:22:35
问题 Consider the example below. Class a has private const SOMETHING , but class b has protected const SOMETHING . class a { private const SOMETHING = 'This is a!'; public static function outputSomething() { return static::SOMETHING ?? self::SOMETHING; } } class b extends a { protected const SOMETHING = 'This is b!'; } echo (new b())::outputSomething(); Output: This is b! But now if I comment out the definition for SOMETHING in class b, an error is thrown: class a { private const SOMETHING = 'This

PHP7 - Connect to sybase database

天大地大妈咪最大 提交于 2019-12-12 09:58:44
问题 http://php.net/manual/en/function.sybase-connect.php is removed as from PHP7. So now I am gettings this error: PHP Fatal error: Uncaught Error: Call to undefined function sybase_connect() How am I supposed to connect to sybase now with PHP7? 回答1: You are using Ubuntu 16.04, so after installation of php7.0-sybase package in your system, you are able to connect with Sybase database using pdo_dblib Example #1 PDO_DBLIB DSN examples sybase:host=localhost;dbname=testdb Following general PDO