Tag Archives: php

[Solved] Git error: You have not concluded your merge (MERGE_HEAD exists)

Enter the root directory of the website

Solution 1: keep the local changes and stop merging – & gt; Re merge – & gt; Pull again

$:git merge --abort
$:git reset --merge
$:git pull

Solution 2: discard the local code, and the remote version will cover the local version (be careful)

$:git fetch --all           //Repulling
$:git reset --hard origin/master //git reset --hard reverts master back to origin/master and ignores all new commits
$:git fetch

PHP read ini configuration error syntax error, unexpected ‘=’In

Error information

Warning: syntax error, unexpected '=' in src/web/../conf/config.ini on line 12

reason

[start_url]
site1=https://baidu.net/home.php?mod=space&uid=0000&do=thread&view=333333
site2=https://google.com/forum.php?mo=111

Because start_ The URL contains the URL, which must be quoted before PHP will report an error. However, it is not a problem to read it in Python.

terms of settlement

Add the parameter ini when reading_ SCANNER_ RAW

$file = __DIR__ . "/../conf/config.ini";
$config = parse_ini_file($file, true, INI_SCANNER_RAW);

JDK installation exception link it with ‘- Z noexecstack’ and inux 64 bit zendguardloader.so: wrong elf class: elfclass32 error handling

N1.
It’s highly recommended that you fix the library with ‘execstack -c <libfile>’, or link it with ‘-z noexecstack’.
It means that it is recommended to use sunjdk instead of linux’s own openjdk

N2.linux 64bit system ZendGuardLoader.so: wrong ELF class: ELFCLASS32 error
1. Download Zend Guard
32位 http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
64位 http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
mkdir /usr/local/zend
tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
sudo cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php5.3.x/ZendGuardLoader.so /usr/local/zend/
2. Set
vim /etc/php.ini
Finally add.
zend_extension=/usr/local/zend/ZendGuardLoader.so
The reason for the above error is that the 64-bit system is using the 32-bit ZendGuardLoader.so.
The solution is to download a 64-bit ZendGuardLoader.so file that corresponds to the PHP version
1、Download Zend Guard
32位 http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
64位 http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
mkdir /usr/local/zend
tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
sudo cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php5.3.x/ZendGuardLoader.so /usr/local/zend/
2. Set
vim /etc/php.ini
Finally Add:
zend_extension=/usr/local/zend/ZendGuardLoader.so

[Solved] has been blocked by CORS policy: Response to preflight request doesn‘t pass access control check: No

Has been blocked by CORS policy: response to preflight request doesn’t pass access control check: no ‘access control allow origin’ header is present on the requested resource.
seeing this error in the webpage, I know that it must be a cross domain problem of Ajax requests.
there are two solutions to this problem, as you should know after reading my article, Before I sent the front-end solution, I don’t know how to flip through my article list
today we talk about the server-side solution
add this code before the JSON data to be returned:


// Specify to allow access to other domains
header('Access-Control-Allow-Origin:*');
// Response type
header('Access-Control-Allow-Methods:POST');
// response header settings
header('Access-Control-Allow-Headers:x-requested-with,content-type');

Here is the PHP code, you can also change it to the corresponding java code.

PHP try will also throw an exception if it is executed successfully

PHP try will also throw an exception if it is executed successfully

try{
    Do something.
    Db::commit();
    return "success":
}cathe(\Exception $exception){
    Db::rollback();
    return "error":
}

Many of the returned results you get directly here, no matter whether your operation is successful or not, are returned as exceptions and go into error
Print exception error:

var_dump($e->getMessage());

The result is

"" 

There is no information
at this time, it should be noted that the return in the exception try will be thrown as an exception. There are two solutions.

First:
will

catch (\Exception $exception)

Change to (eg: use tp6, please rewrite the specific path within the framework)

catch (\think\Exception\DbException $exception)

Second:
save the information that needs to return in the variable, and finally output:

$_retData = [];
try{
    Do something.
    Db::commit();
    $_retData['data'] = [];
    $_retData['messages'] = "success";
}cathe(\Exception $exception){
    Db::rollback();
    return "error":
}
return $_retData;

[Solved] PhpSpreadsheet Error: Invalid cell coordinate [1

When TP5 uses phpspreadsheet, if the number of columns exceeds 26, it will report an error. The specific solutions are as follows: it is easy to use by personal test

//Write to the table header section to read
  // Set the table header
  // $head formatted as ['Name', 'Phone', 'Contact']
        $colum = 'A';
        foreach ($head as $v) {
            $sheet->setCellValue($colum . '1', $v);
            $sheet->getColumnDimension($colum)->setWidth(20);
            $colum++;
        }
        //Write content to read
          $column = 2;
        foreach ($data as $key => $rows) {
            $span = 'A';
            // Column Write
            foreach ($rows as $keyName => $value) {
                $sheet->setCellValue($span . $column, $value);
                $span++;
            }
            $column++;
        }

Creating Server TCP listening socket 127.0.0.1:6379: bind: No error。。。 Solutions to problems encountered in startup

Creating Server TCP listening socket 127.0.0.1:6379: bind: No error。。。 Solutions to problems encountered in startup

D:\redis>redis-server.exe redis.windows.conf
[9952] 03 Jul 15:48:22.538 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error

D:\redis>redis-cli.exe
127.0.0.1:6379> shutdown
(0.51s)
not connected> exit

D:\redis>redis-server.exe redis.windows.conf
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 3.2.100 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._   /    _.-'    |     PID: 16908
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

[16908] 03 Jul 15:49:06.195 # Server started, Redis version 3.2.100
[16908] 03 Jul 15:49:06.246 * DB loaded from disk: 0.049 seconds
[16908] 03 Jul 15:49:06.246 * The server is now ready to accept connections on port 6379

How to Solve opcache error: zend_mm_heap corrupted

There are always problems with production. It seems that the memory is full, which makes it impossible to request

situation:

1. Machine clusters are built with containers
2. The request always appears 502, and it will appear after restarting PHP FPM

3. Open the error log configuration

Of course, you can’t turn off opcache directly. You will find that there is no cache. The memory is very high

Open the error log, and the log will appear in/var/log/PHP FPM/error.log

VI/etc/php-fpm.d/w8002.conf # select different conf files according to which group you want to change
Add a line at the end: catch_ workers_ output = yes

Php5.6 has been reported Zend_ mm_ Heap corrupted with standard PHP 5.6: locating the cause and “Zend”_ mm_ “Heap corrupted” looks like a memory explosion. After a turn, it’s the problem of opcache. Try to disable it, modify the configuration in php.ini and restart PHP FPM

View PHP error log

[root@ip php-fpm]# grep zend error.log | tail -n 3
[01-Jun-2021 00:21:01] WARNING: [pool www8002] child 20812 said into stderr: "zend_mm_heap corrupted"
[01-Jun-2021 00:27:49] WARNING: [pool www8002] child 32582 said into stderr: "zend_mm_heap corrupted"
[01-Jun-2021 00:28:06] WARNING: [pool www8002] child 339 said into stderr: "zend_mm_heap corrupted"

cat php.ini | grep "opcache"
1. /etc/php.d/opcache.ini 改 "opcache.enable=0"
2. systemctl restart php-fpm

Key point: of course, you can’t turn off opcache directly. You will find that the cache memory is too high, so you can’t turn off opcache directly. Let’s start tuning opcache

; switch on
opcache.enable=1

; available memory, as appropriate, in megabytes
opcache.memory_consumption=256

Maximum number of files to cache, try to increase this value if the hit rate is less than 100%
opcache.max_accelerated_files=5000

opcache.max_accelerated_files=5000 ; Opcache will check the modification time of files within a certain period of time, here set the check time period, the default is 2, in seconds
opcache.revalidate_freq=240

The memory size of the interned string, also adjustable
opcache.interned_strings_buffer=8   

whether to fast shutdown, the speed of reclaiming memory will be increased when PHP Request Shutdown is turned on
opcache.fast_shutdown=1

Do not save file/function comments
opcache.save_comments=0

Reference Links:
1.https://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean
2.https://stackoverflow.com/questions/50769286/zend-mm-heap-corrupted-with-standard-php-5-6-locating-the-cause

[Solved] Request exceeded the limit of 10 internal redirects due to possible configuration error

//httpd error log error:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase 
the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://127.0.0.1/MyProject/login/userLogin

Most of the answers on the Internet are about. Htaccess, but I don’t think there’s anything wrong with local HTaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond   %{REQUEST_FILENAME} !-f
    RewriteRule   ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule  ^$ apg/public/    [L]
    RewriteRule  (.*) apg/public/$1 [L]
</IfModule>

The url is correct

http://127.0.0.1/MyProject/login/userLogin

But the page doesn’t display the right content.
Let me see where the framework needs to be changed. I still think the framework hasn’t changed.
Solutions:
Later, I checked my collection.php, and there was an array in it, and I added the name of MyProject MyProject:

 static private $ProjectsArray = array(
            'project1',
            'project2',
            'project3',
            'MyProject'
);

The problem solved! Check my localhost page again and you can visit my Project login page. The framework has been set up successfully!