In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the most common mistakes encountered by PHP and their solutions". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the most common mistakes encountered by PHP and their solutions".
Error one: Parse error: syntax error, unexpected...
This error is that the PHP parser encountered a syntax error while parsing, which is literally translated as:
Parsing error: syntax error, unexpected.
Usually when we write code, the syntax format is not correct, for example: every sentence should end with an English semicolon, if you do not write a semicolon, or typed into a Chinese semicolon, such an error will be reported. This error will also occur in many grammatical errors.
Error 2: Fatal error: Uncaught Error: Call to undefined function...
The code encountered a fatal error during execution, which was literally translated as:
Fatal error: uncaught error: an undefined function was called.
This error is actually very easy to solve, because the prompt is very obvious, that is, look at the line in which the error is reported, find this line, and carefully check whether the function name used in this line is misspelled. Solution: since the prompt calls an undefined function, that is, the function name is not recognized, it must be that the wrong function name or custom function is really undefined.
Error 3: Notice: Array to string conversion in...
This error is the most common for beginners, just a prompt error, at a very low level, and does not affect the execution of the entire code. The PHP program interrupts execution when a Parse error or Fatal error occurs.
The error message can be understood as a hint: the array is in the … Convert lines to strings
It is usually caused when an array is output after the echo, or when the array is concatenated as a string. Because PHP is a weakly typed programming language, it automatically converts data types according to the needs of the environment. The solution is to find the prompt line and process the array in advance before performing a string operation.
Error 4: Parse error: syntax error, unexpected'1' (T_LNUMBER), expecting variable...
This is prompted when there is a syntax error that cannot be parsed by PHP. Unexpected is unexpected. There is also a hint that expecting means that you want to appear. . Generally, this error is reported when the names of variables, functions, and so on do not conform to the naming syntax specification. The solution is to carefully check whether the wrong line is named correctly.
Error 5: Warning: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, boolean given...
This error is a warning error and does not affect the execution of the program. Usually when the database reads the result set data, it is more difficult for beginners to find the wrong solution, because the error cannot be found by prompting the line.
Literally translated as:
Warning: the mysqli_fetch_assoc function expects argument 1 to be the result set of mysqli, but gives a Boolean value.
In other words, when we write the SQL statement to read data from the database, we should return the result set itself, and then read the data to the result set. However, the result set is a Boolean value, so it is most likely that the SQL statement is miswritten, resulting in an execution error, and the result set becomes the execution result false.
Solution: carefully check the SQL statement, it is best to output the spliced SQL statement to have a look, make sure there is no problem and then submit it to the server for execution.
Error 6: Notice: Undefined variable:...
Hint: no variable an is defined
This error is reported when an undefined variable is used, which can be solved by carefully checking the definition or spelling of the variable.
Error 7: Notice: Undefined index: username in...
Hint: undefined index: username
Usually in the use of an undefined array elements will appear, PHP has a special associative array, you can use the key name to access the value, in the prompt is also prompted by the index array, so it is easy to cause beginners to misunderstand. The solution is to check carefully to see if the array key name is misspelled or undefined.
Error 8: garbled code
When we see an incomprehensible symbol, a messy traditional Chinese character or a question mark on a web page, we call it garbled. This is due to the fact that the character set when PHP generates HTML code is different from the character set displayed by the browser by default.
Solution:
Add the response header declaration character set at the top of the PHP code (before any output statement):
Thank you for your reading, the above is the content of "the most common mistakes encountered by PHP and their solutions". After the study of this article, I believe you have a deeper understanding of the problems that PHP most often encounter and their solutions, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.