Tag Archives: PHP Error

[Solved] PHP Error: Warning: file_get_contents(): Failed to enable crypto

I. Description
file_get_contents() error when reading https content

II. Reason
Local service is not configured ssl certificate, can not get the contents of the path to https

III. Solution
1, Linux server configuration https ssl certificate.
Linux server configuration https ssl certificate.
2. curl_ request to obtain the content (see the following method curlGet ())

    /**
     * get the content
     * @param $url
     * @return bool|string
     */
    function curlGet($url)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $content = curl_exec($ch);
        curl_close($ch);
        return ($content);
    }

3.Use file_get_contents() function to skip https authentication

        $streamOpts = [
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false
            ]
        ];
        $html = file_get_contents($pageUrl, false, stream_context_create($streamOpts));

[PHP] Array to string conversion error when sending data in post

When using curl to pass post data, if the data field is an array, an error will be reported Array to string conversion

When calling curl_setopt_array($curl, $options);

Call curl_setopt($ch, CURLOPT_POSTFIELDS, $data)

Errors may be reported in these two places, the solution is to process the data array

http_build_query($data)

How to Solve PHP Error: no package’oniguruma’ found

When compiling and installing php, if –enable-mbstring, the mbstring extension is enabled, this regular processing library is required

 

centos

yum install http: // rpms.remirepo.net/enterprise/7/remi/x86_64 // oniguruma5-6.9.4-1.el7.remi.x86_64.rpm 
yum install http: // rpms.remirepo.net/enterprise/ 7/remi/x86_64 // oniguruma5-devel-6.9.4-1.el7.remi.x86_64.rpm

ubuntu

apt install libonig-dev

composer Error while processing content unencoding: Unknown failure within decompression softwar

On Composer download file Error [Composer\Downloader\TransportException] Error while Processing content unencoding: Unknown failure within decompression Software. After checking the results returned after running the command, it was found that the problem was not due to compression expansion. The package information was loaded from the local cache and may be out of date. So you can just clear the Composer local cache

Composer clears the cache: Composer ClearCache