PHP basic Knowledge "functions" (8) XML and variable functions

Source: Internet
Author: User
Tags processing instruction scalar xml parser

First, the XML function

Parameter type

Data--string, a dataset that needs to be parsed.

parser--resource, a reference to the XML parser to get the byte index.                     

1. Creating and releasing XML parsers

Xml_parser_create ([string encoding])--Creates a new XML parser and returns a resource handle that can be used by other XML functions.

Xml_parser_free (parser)--releases the specified XML parser  

2. get error Messages

Xml_error_string (code)-Gets the XML parser error string based on the given code. Code returned by Xml_get_error_code ().

Xml_get_error_code (parser)--Gets the XML Parser error code (int).  

3, get the current parser index, column number, line number

Xml_get_current_byte_index (parser)--Gets the current byte index (int) of the specified XML parser.

Xml_get_current_column_number (parser)--Gets the current column number (int) of the specified XML parser.

Xml_get_current_line_number (parser)--Gets the current line number (int) of the specified XML parser.  

4. Set Parser information

Xml_parser_get_option (parser, int option)--Get option settings information from the XML parser

Xml_parser_set_option (parser, int option, mixed value)--option setting for specifying XML parsing

Xml_set_object (Parser, Object &object)--Using an XML parser in an object  

5, character transcoding

Utf8_encode (data)--converts a string to UTF-8 encoding and returns the encoded string

Utf8_decode (data)--decoding iso-8859-1 encoding with UTF-8 encoding  

6. Build the processor

Xml_set_default_handler (parser, callback handler)--establishing the default processor

Xml_set_character_data_handler (parser, callback handler)--building character data processors

Xml_set_external_entity_ref_handler (parser, callback handler)--establishing an external entity to point to the processor

Xml_set_unparsed_entity_decl_handler (parser, callback handler)--establishing an unresolved entity definition declaration processor

Xml_set_start_namespace_decl_handler (parser, callback handler)--establishing a start namespace declaration processor

Xml_set_end_namespace_decl_handler (parser, callback handler)--establishing a terminating namespace declaration processor

Xml_set_notation_decl_handler (parser, callback handler)--establishing the annotation declaration processor

Xml_set_processing_instruction_handler (parser, callback handler)--Establishing a processing instruction (PI) processor

Xml_set_element_handler (parser, callback Start_element_handler, callback End_element_handler)--establishment of start-up and termination Element Processor

7. Other

Xml_parse_into_struct (parser,data,values [, index])--parses the XML file into two corresponding arrays, and the index parameter contains a pointer to the corresponding value in the values array.

Xml_parse (Parser,data [, BOOL is_final])-Parse the XML document. The processor for the configured event is called indefinitely as needed.

Is_final: If set to TRUE, data is the last segment of the current resolution, and the project's error will be reported at the end of the data.

Second, variable function 

1. Variable detection

empty (mixed Var)--Checks if a variable is empty, and empty () returns FALSE if Var is a non-null or nonzero value. Returns TRUE if Var is empty.

Isset--detect if the variable is set

Is_array--detects if a variable is an array

Is_bool--Whether the detection variable is a Boolean type

Is_float/is_double/is_real--Whether the detection variable is floating point type

Is_int/is_integer/is_long--detects if the variable is an integer

Is_object--detects if a variable is an object

Is_resource--detects if a variable is a resource type

Is_numeric--detects if a variable is a numeric or numeric string

Is_string--detects if a variable is a string

is_callable--detect if the parameter is a legitimate callable structure

Is_scalar--detects if a variable is a scalar   

2. Get the value of a variable

Intval--Gets the integer value of the variable  

Strval--Gets the string value of the variable

floatval (mixed var)--Gets the variable's floating-point value, and VAR can be any scalar type. You cannot use Floatval () for arrays or objects.  

3. Setting and getting variable types

Settype (mixed var, string type)--sets the type of the variable

Get_resource_type (Resource handle)--return resource (Resource) type

GetType (mixed Var)--Gets the type of the variable. do not use it because the string it returns may change in future versions. In addition, it runs slower. Use the is_* function instead

4. Other

unset--Deleting variables

Print_r-Print easy-to-understand information about variables.

Var_dump--Information about printing variables

Var_export--Output or return a string representation of a variable

get_defined_vars (void)--Returns an array of all defined variables

Import_request_variables (String types [, String prefix])--Import Get/post/cookie variable into global scope

Serialize--produces a representation of a value that can be stored

Unserialize--Create a PHP value from a stored representation

PHP basic Knowledge "functions" (8) XML and variable functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.