Category Archives: PHP

PHP Error: The use statement with non-compound name

1.1 The use statement with non-compound name

1.1.1 phenomenon

After debugging the program, it is found that running the following code will make the program run away:

require_ once __ DIR__ . ‘/ actions/’ . $refectClass . ‘.php’;

1.1.2 reasons

is debugged in PHPStorm. DIR__ Variable, found that it has always been Xdebug, so thought it was this problem, online search a lot of information, there is no solution

Later, I checked the error log and found the following error information:
2014-05-12 16:41:53: < E> [ php ]: The use statement with non-compound name 'CommonUtils' has no effect (D:\ProjectWork\SourceCode\Server\i2goods\protected\components\clientapi\actions\BookEditAction. php:9 )
Open the bookeditaction.php file and look at line 9 of the code

use CommonUtils
Looking for information on the Internet, we found that this use syntax error

1.1.3 solution

Consult the relevant developers, this code is garbage code, forget to delete, delete it

php_network_getaddresses: getaddrinfo failed

In general, when calling external service requests, sometimes due to configuration problems, PHP will report a PHP_ network_ Error in getaddresses: getaddrinfo failed: name or servicenot known:

 

reason:

PHP host cannot connect to DNS server

Analysis: for example, what is your access request www.leyangjuntestxxxx.com Our services

You can: Ping or   Telnet to see whether the domain can be accessed, whether there is a response

If you can’t Ping, your service is connected to a DNS server with problems

 

General solution:

1: You need to check whether the requested remote host is in/etc/hosts of the local machine

2: Need to check the rules of the firewall, is it blocked by the response

3: You can manually bind the host in the/etc/hosts file

Wnmp environment configuration (Windows + nginx + MySQL + PHP)

1. Packages to be prepared:
nginx: http://nginx.org Here I download the latest version of 1.11.13
PHP: http://windows.php.net/download (Note: PHP in nginx runs in fastcgi mode, so download PHP package of non ready-made security NTS)
runhiddenconsole: RunHiddenConsole.zip Used to write quick start and stop programs

2. Installation and configuration. Create a new directory D: wnmp
1. Installation and configuration of PHP:
decompress and rename the downloaded PHP package php-5.6.30-nts-win32-vc11-x64 to PHP5 to form the path D: wnmp Go down and find it

;extension=php_mysql.dll
;extension=php_mysqli.dll

Remove the front “;” and add MySQL extension to make PHP support mysql. Later, you can add other extensions as needed, all of which are to remove the semicolon.
Next, configure PHP to work with nginx. Find out; cgi.fix_ Pathinfo = 1, remove the semicolon. This step is very important. This is the CGI setting of PHP.

cgi.fix_pathinfo=1

2. Nginx installation and configuration:
unzip the downloaded nginx-1.11.13 package to the wnmp directory, named nginx. Enter the nginx/conf directory and open the configuration file nginx.conf , find

location/{
  root  html;  #This is the root directory of the site, in nginx/html
  index index.html index.htm;
}

Change to:

location/{
    root  D:/wnmp/www;  #Specify the site root directory as D:/wnmp/www
    index index.php index.html index.htm; # Add index.php, giving priority to parsing php files
}

Further down, find it

#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}

First, remove the previous “#”, then change root HTML; to root D/wnmp/www, and then change/scripts to $document_ Root, here’s “$document_ “Root” is the site path specified by “root” above. The results are as follows

location ~ \.php$ {
    root           D:/wnmp/www;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

Just save the configuration file. In this way, the environment of nginx + PHP is initially configured. You can enter the command to start PHP, and start nginx manually, and create a new one in the directory D:: (wnmp) www phpinfo.php File to test whether it works.

3. Write quick start and stop scripts
to download the RunHiddenConsole.zip The files are decompressed and stored in the directory D/wnmp (or nginx), RunHiddenConsole.exe The function of the script is to automatically close the script after executing the command line script, and the process opened in the script will not be closed. Create a script named“ start.bat “, the content is as follows:

@echo off
REM Windows 
REM set PHP_FCGI_CHILDREN=5

REM Maximum number of requests per process, or set as a Windows environment variable
set PHP_FCGI_MAX_REQUESTS=1000

echo Starting PHP FastCGI...
RunHiddenConsole D:/wnmp/php5/php-cgi.exe -b 127.0.0.1:9000 -c D:/wnmp/php5/php.ini

echo Starting nginx...
RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx

Create another one called“ stop.bat “To close nginx and PHP:

@echo off

echo Stopping nginx...
taskkill /F /IM nginx.exe > null

echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > null

exit

After completion, the D/wnmp directory is as follows:

In this way, the service scripts are created. double-click start.bat You can see that there are two in the process manager nginx.exe Process and a PHP- cgi.exe Process.

3、 test: create a new file in the site directory D/wnmp/www phpinfo.php The contents are as follows:

<?php
	phpinfo();	
?>

After saving, the browser accesses“ http://localhost/phpinfo.php ”, see the following information, that windows nginx + PHP development environment has been configured successfully!

Testing MySQL database connection: please see another article about MySQL service. Under D/wnmp/www, create a new index.php The contents are as follows:

<?php 
	if (mysqli_connect("localhost","root","root")) {
		echo "successful!";
	}else{
		echo "error...";
	}
 ?>

Browser anti question“ http://localhost/index.php “, see the following prompt successful! It indicates that all wnmp development rings are configured successfully!

improvement: in step 3 above, when writing quick start script, use% ~ DP0 instead of absolute path D/wnmp .

@echo off
REM Windows
REM set PHP_FCGI_CHILDREN=5

REM Maximum number of requests per process, or set as a Windows environment variable
set PHP_FCGI_MAX_REQUESTS=1000

echo Starting PHP FastCGI...
RunHiddenConsole %~dp0/php5/php-cgi.exe -b 127.0.0.1:9000 -c %~dp0/php5/php.ini

echo Starting nginx...
RunHiddenConsole %~dp0/nginx/nginx.exe -p %~dp0/nginx

% – DP0 refers to the current drive letter plus path, which can only be used in batch file. Bat. works the same as% CD%, but% CD% can be used in batch files or on the command line.

In this way, when the wnmp folder path changes (such as moving from disk d to disk E), there is no need to change the script file.

How to Solve PHP error “Zend”_ mm_ heap corrupted”

I: Environment Introduction
Ali cloud  
[machao@gksn]$ cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core) 
There is a local test environment and an online environment, the online environment is placed in svn
[machao@iZ233xdnwmfZ ~]$ php -v
PHP 5.6.20 (cli) (built: Apr 9 2016 20:40:37) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies


Link: https://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean

2: Content of error report

A function of the website suddenly fails to work. Click in to display “502 bad gateway”, but the test environment is normal

At that time, the first reaction was that the problem with nginx was due to the network. After looking at the nginx status, it was still not possible to refresh the browser page. PHP page, and then think of other sites to check- fpm.log Error file for

tail -f /usr/local/php56/var/log/php- fpm.log

[16-May-2018 11:30:28] WARNING: [pool www] child 32494 said into stderr: “zend_ mm_ heap corrupted”
[16-May-2018 11:30:28] WARNING: [pool www] child 32494 exited with code 1 after 534.670302 seconds from start
[16-May-2018 11:30:32] WARNING: [pool www] child 32521, script ‘/web/zwbi/admin/public/ index.php ‘ (request: “GET/index.php “) executing too slow (5.745961 sec), logging

3: Solutions

1. Memory problem

Open php.ini File to find the next two lines to increase the output_ The buffering value either turns off this option or executes export use on the command line_ ZEND_ Alloc = 0 PS: no use_ ZEND_ Alloc performance will decline sharply, which is PHP’s own memory management mechanism

vim /usr/local/php56/etc/ php.ini

output_ buffering = On
output_ buffering = 25600

Restart PHP FPM

Sudo systemctl restart/usr/local/php56/SBIN/PHP FPM

2. chown -R www.www filename && chmod 777 filename

But it’s still 502

 

3. Check nginx error log and PHP- fpm.log Log

[06-Mar-2018 15:54:57] WARNING: [pool www] child 30396 said into stderr: "zend_mm_heap corrupted" [06-Mar-2018 15:54:57] WARNING: [pool www] child 30396 exited with code 1 after 239.805753 seconds from start

 

Baidu and Google inquired about some links and “determined that it was the problem of opcache module”. At that time, they thought it could be basically solved. But it’s useless to comment out the whole opcache module. Link posted below, did not solve my problem, may be helpful to friends.

https://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean
https://github.com/websharks/comet-cache/issues/705

4. I think it is a problem of some dependent components, so I update the composer package of the test environment to the formal environment, and the test still fails. After the test fails, restore the component (do these operations must remember to backup, restore at any time).

5. There are differences with development. I think there may be a problem with the code operation, such as a bug or the associated file permissions. I think it’s my environment problem. Do as you say, set the authority of all files in the formal environment at one time.

sudo chown -R www.www /web/xxx

At this point, the problem remains unsolved

6. Code problems

Develop the code version before rollback, and solve the problem