How to include php source line number in user error message?

I want to make my own error generator when I program (HTML + PHP). How can I take a string when I have an error and insert a variable?

Example:

echo "Error # 03: variable undefined string # ". $ line. " ";

Thank.

+3
source share
3 answers

the variables you are looking for:

__LINE__
__FILE__
__FUNCTION__
__CLASS__
+2
source

there is a predefined constant, __LINE__which contains the string in which it was actually called.

, , trigger_error() " ", . , , PHP, - - ,

debug_backtrace().

+2

, PHP , . ( , script ), , .

If PHP does not display error messages, use the following code to display all PHP error messages and warnings on the page:

error_reporting(E_ALL);
0
source

Source: https://habr.com/ru/post/1795611/


All Articles