Tag Archives: PHP Error

[Solved] ini_set(“display_errors”,”On”); & error_reporting(E_ALL);

When using PHP to do website development, in order to prevent users from seeing error messages, the unfriendly interface appears. Therefore, it is generally set in php.ini:

display_ errors = Off;
However, sometimes we need to open error messages during development. At this time, you can set the following in the PHP file:

ini_ set("display_errors","On");
error_ reporting(E_ ALL);

However, sometimes we can’t display the syntax errors in PHP even if we set it like this in time

solution:
suppose there are syntax errors in this PHP file.
you can create a new test.php and edit it in this PHP as follows:
ini_ set(“display_ errors”,”On”);
error_ reporting(E_ ALL);
include (“target file”)

error_ reporting(“E_All “) and ini_set(“display_errors” and “on”),  What is the difference?

If the latter is off, the former is useless even for e-all

How to Solve PHP Error: Function name must be a string

 

PHP low level error: function name must be a string technology

In my impression, this kind of PHP error is rarely encountered, but once encountered, all of a sudden still can not find the problem

When a person is very tired in the process of development, he makes a low-level mistake. He looks at the screen and doesn’t know why, so the whole network looks for the answer. PHP error: function name must be a string appears in the following code

<?php

$_GET('name');

$_POST('name');

$_COOKIE('name');

?>

Function name and method name must be a string, which is easy to mislead people. PHP 5.3 has started to support anonymous functions, and variables can also be used as functions

 

[PHP Error]Only variables should be passed by reference

PHP Error: Only variables should be passed by reference

A PHP Error was encountered  
Severity: Runtime Notice  
Message: Only variables should be passed by reference  

$file_name = $_FILES[$upload_name][‘name’];
$file_extension = end(explode(‘.’, $file_name)); //ERROR ON THIS LINE

Reason for error reporting:

Getting the suffix name with the end function points the internal pointer of the array to the last element, while end is a reference to pass the value。

The problem is, that end requires a reference, because it modifies the internal representation of the array (i.e. it makes the current element pointer point to the last element).

The result of explode(‘.’, $file_name) cannot be turned into a reference. This is a restriction in the PHP language, that probably exists for simplicity reasons.

The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

Solution:

(1) Define a variable to get the value after explode, then use the end function to:

$parts = explode('.', $file_name);  
$file_extension = end($parts);  

(2) Use substr and strrchr functions to get the file suffix:

$ext = substr( strrchr($file_name, '.'), 1);  

(3) Use the pathinfo function to get the file suffix:

$file_ext = pathinfo($file_name, PATHINFO_EXTENSION);  

The end() function points the internal pointer of the array to the last element and returns the value of that element, if successful

 

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