- xml_get_current_line_number
- Parameters
- Return Values
- Changelog
- See Also
- User Contributed Notes
- How to get current directory, filename and code line number in PHP
- To get the current directory
- To get the current filename with full file path
- To get the current line number
- How to get current directory, filename and code line number in PHP
- To get the current directory
- To get the current filename with full file path
- To get the current line number
- How to get current directory, filename and code line number in PHP
- To get the current directory
- To get the current filename with full file path
- To get the current line number
- How to get current directory, filename and code line number in PHP
- To get the current directory
- To get the current filename with full file path
- To get the current line number
xml_get_current_line_number
Gets the current line number for the given XML parser.
Parameters
A reference to the XML parser to get line number from.
Return Values
Returns which line the parser is currently at in its data buffer.
Changelog
Version | Description |
---|---|
8.0.0 | parser expects an XMLParser instance now; previously, a valid xml resource was expected. |
See Also
- xml_get_current_column_number() — Get current column number for an XML parser
- xml_get_current_byte_index() — Get current byte index for an XML parser
User Contributed Notes
- XML Parser Functions
- xml_error_string
- xml_get_current_byte_index
- xml_get_current_column_number
- xml_get_current_line_number
- xml_get_error_code
- xml_parse_into_struct
- xml_parse
- xml_parser_create_ns
- xml_parser_create
- xml_parser_free
- xml_parser_get_option
- xml_parser_set_option
- xml_set_character_data_handler
- xml_set_default_handler
- xml_set_element_handler
- xml_set_end_namespace_decl_handler
- xml_set_external_entity_ref_handler
- xml_set_notation_decl_handler
- xml_set_object
- xml_set_processing_instruction_handler
- xml_set_start_namespace_decl_handler
- xml_set_unparsed_entity_decl_handler
How to get current directory, filename and code line number in PHP
PHP provides a large number of magical constants. All these constants are case sensitive. With the help of these constants, we can get the current directory, filename, current line number and much more. It is more secure, reliable, and fast, which has resulted in web developers preferring to work with PHP. So, it does not matter if the developer needs to know the line number or current directory of the PHP document.
These are some examples of PHP Magic Constants.
To get the current directory
__DIR__: This constant is used to get the current directory of the file. This is equivalent to the dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. If used inside an include method, the directory of the included file is returned.
echo "The current directory of this file is '" . __DIR__ . "'.\n"; ?>
Output: The current directory of this file is ‘C:\wamp\www\demo’.
To get the current filename with full file path
__FILE__: This is used to return the full file path and filename of the file. If used inside an include method, the name of the included file is returned.
echo "The current file with path is '" . __FILE__ . "'.\n"; ?>
Output: The current file with path is ‘C:\wamp\www\demo\magic_const.php’.
This magic constant is mostly used in case where we have to include some files from the directory.To get the current line number
__LINE__: This is used to return the current line number of the file.
echo "The line number of this code is '" . __LINE__ . "'.\n"; ?>
Output: The line number of this code is ’34’.
This constant is mostly used while debugging the code or to get line number of the error.How to get current directory, filename and code line number in PHP
PHP provides a large number of magical constants. All these constants are case sensitive. With the help of these constants, we can get the current directory, filename, current line number and much more. It is more secure, reliable, and fast, which has resulted in web developers preferring to work with PHP. So, it does not matter if the developer needs to know the line number or current directory of the PHP document.
These are some examples of PHP Magic Constants.
To get the current directory
__DIR__: This constant is used to get the current directory of the file. This is equivalent to the dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. If used inside an include method, the directory of the included file is returned.
echo "The current directory of this file is '" . __DIR__ . "'.\n"; ?>
Output: The current directory of this file is ‘C:\wamp\www\demo’.
To get the current filename with full file path
__FILE__: This is used to return the full file path and filename of the file. If used inside an include method, the name of the included file is returned.
echo "The current file with path is '" . __FILE__ . "'.\n"; ?>
Output: The current file with path is ‘C:\wamp\www\demo\magic_const.php’.
This magic constant is mostly used in case where we have to include some files from the directory.To get the current line number
__LINE__: This is used to return the current line number of the file.
echo "The line number of this code is '" . __LINE__ . "'.\n"; ?>
Output: The line number of this code is ’34’.
This constant is mostly used while debugging the code or to get line number of the error.How to get current directory, filename and code line number in PHP
PHP provides a large number of magical constants. All these constants are case sensitive. With the help of these constants, we can get the current directory, filename, current line number and much more. It is more secure, reliable, and fast, which has resulted in web developers preferring to work with PHP. So, it does not matter if the developer needs to know the line number or current directory of the PHP document.
These are some examples of PHP Magic Constants.
To get the current directory
__DIR__: This constant is used to get the current directory of the file. This is equivalent to the dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. If used inside an include method, the directory of the included file is returned.
echo "The current directory of this file is '" . __DIR__ . "'.\n"; ?>
Output: The current directory of this file is ‘C:\wamp\www\demo’.
To get the current filename with full file path
__FILE__: This is used to return the full file path and filename of the file. If used inside an include method, the name of the included file is returned.
echo "The current file with path is '" . __FILE__ . "'.\n"; ?>
Output: The current file with path is ‘C:\wamp\www\demo\magic_const.php’.
This magic constant is mostly used in case where we have to include some files from the directory.To get the current line number
__LINE__: This is used to return the current line number of the file.
echo "The line number of this code is '" . __LINE__ . "'.\n"; ?>
Output: The line number of this code is ’34’.
This constant is mostly used while debugging the code or to get line number of the error.How to get current directory, filename and code line number in PHP
PHP provides a large number of magical constants. All these constants are case sensitive. With the help of these constants, we can get the current directory, filename, current line number and much more. It is more secure, reliable, and fast, which has resulted in web developers preferring to work with PHP. So, it does not matter if the developer needs to know the line number or current directory of the PHP document.
These are some examples of PHP Magic Constants.
To get the current directory
__DIR__: This constant is used to get the current directory of the file. This is equivalent to the dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. If used inside an include method, the directory of the included file is returned.
echo "The current directory of this file is '" . __DIR__ . "'.\n"; ?>
Output: The current directory of this file is ‘C:\wamp\www\demo’.
To get the current filename with full file path
__FILE__: This is used to return the full file path and filename of the file. If used inside an include method, the name of the included file is returned.
echo "The current file with path is '" . __FILE__ . "'.\n"; ?>
Output: The current file with path is ‘C:\wamp\www\demo\magic_const.php’.
This magic constant is mostly used in case where we have to include some files from the directory.To get the current line number
__LINE__: This is used to return the current line number of the file.
echo "The line number of this code is '" . __LINE__ . "'.\n"; ?>
Output: The line number of this code is ’34’.
This constant is mostly used while debugging the code or to get line number of the error.