Bug and Debug in PHP
The program rarely works correctly right from the first time. Many things can be wrong in the program causing the PHP interpreter to generate an error message. You can choose where this error message appears.
The program rarely works correctly right from the first time. Many things can be wrong in the program causing the PHP interpreter to generate an error message. You can choose where this error message appears. Messages can be sent along with other program output to the web browser. They can also be included in the error log on the Web Server.
To make the error message appear in the browser, set the directive to display__errors to On . To send errors to the error log on the Web Server, set log_errors to On. If you want to report an error at both locations, you can set these two directives to On.
PHP defines a number of constants that you can use to set the value of error_reporting , so that only specific error types are reported: E_ALL (for all exceptions except strict notice), E_PARSE (parse error), E_ERROR (Fatal error), E_WARNING (warning), E_NOTICE (notice), and E_STRICT (strict notice).
While writing PHP programs, using editors that can identify PHP like BBEdit or Emacs is a good idea. One of the special features of these Editor is syntax highlighting. It changes the color of different parts of the program based on what those parts are. For example, PHP strings are pink, keywords like if PHP, while are blue, comments are gray, and PHP variables are black.
Another feature is matching quotes and parentheses, to ensure that your citations and parentheses are balanced. When you type a close parenthesis, for example}, Editor will highlight the opening parenthesis {matches it.
Dưới đây là các điểm quan trọng cần kiểm tra trong khi debug chương trình của bạn: Here are the important points to check while debugging your program:
- Thiếu dấu chấm phảy (;): Mỗi lệnh PHP kết thúc với một dấu chấm phảy (;). Missing semicolon (;): Each PHP command ends with a semicolon (;).PHP không dừng đọc một lệnh tới khi nó gặp một dấu chấm phảy. PHP does not stop reading a command until it encounters a semicolon.Nếu bạn quên dấu chấm phảy ở cuối dòng, PHP tiếp tục đọc lệnh trên dòng tiếp theo. If you forget the semicolon at the end of the line, PHP continues to read the command on the next line.
- Không đủ dấu bằng (=) : Khi bạn hỏi hai giá trị có bằng nhau không trong một lệnh so sánh, bạn cần hai dấu bằng (==). Not enough equals sign (=) : When you ask if the two values are equal in a comparison command, you need two equals (==).Sử dụng một dấu bằng là một lỗi phổ biến. Using an equal sign is a common error.
- Tên biến viết sai chính tả : Nếu bạn viết sai chính tả một biến thì PHP hiểu nó như là một biến mới. Misspelled variable name : If you misspell a variable, PHP understands it as a new variable.Nhớ rằng, với PHP, $test và $Test không giống nhau. Remember, with PHP, $ test and $ Test are not the same.
- Thiếu ký hiệu $ : Quên ký hiệu $ trong tên một biến là hiếm khi gặp, nhưng nếu thiếu, nó sẽ tạo một thông báo lỗi để bạn biết nơi xảy ra vấn đề. Missing $ symbol : Forgetting the $ symbol in a variable name is rare, but if it is missing, it will generate an error message so you know where the problem occurred.
- Vấn đề về trích dẫn : Bạn có thể có quá nhiều, quá ít trích dẫn hoặc bị lỗi trích dẫn. Citation problem : You may have too many, too few citations or excerpt errors.Vì thế bạn nên kiểm tra thật kỹ các trích dẫn. So you should carefully check the citations.
- Thiếu dấu ngoặc đơn hoặc dấu ngoặc ôm : Các dấu ngoặc này luôn đi kèm thành một cặp (), {}, []. Missing parentheses or parentheses : These brackets are always enclosed in a pair (), {}, [].
- Array index : All arrays start at 0 rather than 1.
Also, handle all errors appropriately and send all trace messages into the system log file, so that if any problems occur, it will be written in log file and you can debug that problem.
Follow tutorialspoint
Previous lesson: Regular Expression in PHP
Next lesson: Date & Time in PHP
You should read it
- How to enable USB Debugging mode on Android
- Microchip MPLAB PICkit 4, a new tool that supports debugging 5 times faster and low cost programming
- How to Debug Javascript
- How to debug websites on iPad
- How to use Fiddler to collect HTTP / HTTPS sessions for debugging
- How to use Windows Repair to fix Windows errors
- Fix Bluestacks Initializing load errors permanently on the main screen
- Opera released web page debugging tool
- How to Restore Samsung Notes on Samsung Galaxy
- Steps to fix double quotes in Word
- Analysis of Memory Dump file (* .dmp)
- How to transfer notes from Evernote to Mac's Notes
Maybe you are interested
Singapore hospitals use technology to save time and human resources costs Is it better to clean, isolate or delete viruses in malicious files? Review Redmi Note 9: The new low-cost model? 5 simple steps to creating a professional landing page without knowing the code Top 3 best IPL hair removal machines today Top 5 best water toothpick machines today