Tag Archives: php

[Solved] Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path:


Warning: Unknown: Failed to write session data using user-defined save handler. (session.save_path: D:\Software\phpstudy_pro\Extensions\tmp\tmp) in Unknown on line 0

Reasons:

1. the path of session.save_path is not correct
2. session.save_path's file permissions are not correct
3. and other reasons for the error, (but mine is not the problem) this problem sent me a day of time

My mistake:

The session that occurs when using this method_set_save_handler(‘open’,‘close’,‘read’,‘write’,‘destory’,‘gc’);

reason

	1. the read callback function must return the value of the string, if not, other errors will be reported
	2. write callback function must return true, if false will return the above error
	3. write in the insert statement of the variable value must be added to the single quotes, otherwise it can not be inserted into the database
	4. all but the read callback function must return a bool value, write must return true to insert into the database, and the others I think should also return true (not tested here)

Encounter this wrong idea

1. Check the configuration file for errors first
2. then check for errors in the return value
3. then check the sql statement for errors
4. debug with echo or var_dump at each step

If you solve the big guys’ problems, please give me a favor.

Vant configures multiple sites, and new sites 404 error [How to Solve]

1.configure the homestead.yaml file
Add folder mapping, domain name directory mapping (note the layer mapped to the entry file)

2. Configure hosts file

3. Reload vagrant (reload the modified configuration file)

vagrant provision&&vagrant reload

#After reloading the configuration, open vagrant
vagrant up && vagrant ssh

4. Restart nginx

service nginx restart

5. Successfully open the newly added site

PHP: The Difference between \Throwable, \Error and \Exception

\Throwable

It is the exception class that begins to appear in php7.0, and it is the parent class of \error \exception

\Error

Inherited \throwable to handle some internal errors of the system, such as memory overflow

\Exception

Inherited \throwable to handle error reports during program execution, or actively throw exceptions (\error can also throw exceptions)

PHP large file upload error 413: request entity too large [How to Solve]

1. Nginx configuration modification

1. Modify the Nginx.conf (/ etc/Nginx/Nginx.conf) configuration file, and add or modify the following configuration in http{}:

client_max_body_size 20m; 

2. Restart nginx

systemctl restart nginx

2. PHP configuration modification

Find the location of the php.ini file:

Method 1

Use the command whereis php; to view the php related directories, if you can't find the ini file in the listed directories, you can refer to method 2.

Method 2

php --info > a.log;
vim a.log, To view the output, you can directly search for php.ini and you will see the directory where the file is located. As the following screenshot.

1. Modify the php.ini (/etc/PHP.ini) configuration file, find the following configuration and modify it:

post_max_size = 20M  
upload_max_filesize = 20M  

2. Restart PHP FPM

systemctl restart php-fpm

Error reported by thinkphp5 and wdatepicker calendar control

Error reported by thinkphp5 and wdatepicker calendar control

The solution is as follows

{literal}
	<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" class="input-text Wdate" style="width:120px;">
	<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" class="input-text Wdate" style="width:120px;">
{/literal}

ThinkPHP uses literal to prevent template tags from being parsed

[Solved] file_get_contents(): SSL operation failed with code 1

Error content
file_get_contents(): SSL operation failed with code 1.OpenSSL Error messages:\nerror:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

This is related to the local environment. Whether SSL authentication is enabled
solution: modify the configuration or code

$stream_opts = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ]
];  
 
$response = file_get_contents($url, false, stream_context_create($stream_opts));

[PHP]stream_socket_client(): Failed to enable crypto

Problem recurrence:

<?php
function getCertInfo($domain)
{
    $context = stream_context_create([
        'ssl' => [
            'capture_peer_cert'       => true,
            'capture_peer_cert_chain' => true,
        ],
    ]);

    $client = stream_socket_client("ssl://{$domain}:443", $errorCode, $errorMessage, 30, STREAM_CLIENT_CONNECT, $context);
    if ($client === false) {
        var_dump("!!!open {$domain} socket connection fail. {$errorMessage}($errorCode) !!!";
        return false;
    }

    $params = stream_context_get_params($client);
    if (empty($params['options']['ssl']['peer_certificate'])) {
        var_dump("!!!{$domain} stream_context_get_params options ssl peer_certificate is empty!!!");
        return false;
    }

    return openssl_x509_parse($params['options']['ssl']['peer_certificate']);
}

Solution: $context add verify_ Peer configuration

<?php 
$context = stream_context_create([
    'ssl' => [
        'capture_peer_cert'       => true,
        'capture_peer_cert_chain' => true,
        'verify_peer'             => false,
    ],
]);

PHP Fatal error: Uncaught Error: Class ‘\Elasticsearch\Serializers\SmartSerializer‘ not found in /h

  Class file exists, but prompt cannot load “elasticsearch \ serializers \ smartserializer”

PHP Fatal error:  Uncaught Error: Class '\Elasticsearch\Serializers\SmartSerializer' not found in /home/wwwroot/es-task/vendor/elasticsearch/src/Elasticsearch/ClientBuilder.php:488

Find classes that are not loaded directly. Use require_ Once “class name path”;