"PHP" Object-oriented (v)

Source: Internet
Author: User
Tags getmessage

One, type constraints:
A) parameter types that the constraint function can pass in
II. traversal of a class
A) Foreach
b) All member properties in the class can be traversed
Iii. Some functions for manipulating classes and objects:
A) Judgment function
I.function_exists () determine if a function exists
Ii. Class_exists () to determine whether a class exists
b) Magic constants:
i.__file__ get the absolute path to the current file
Ii.__line__ gets the line number where the current code is located
Iii.__functions__ gets the name of the current function
Iv.__method__ gets the name of the current method
V.__class__ get the name of the current file
c) A function that determines the properties and methods:
I.property_exists () detects whether a property in a class is set
Ii. Method_exists () detects whether a method in a class is set
Iii. Get_object_vars () Gets the list of properties in the object
iv. Get_class_vars () Gets the list of properties in the class
V.get_class_methods () Gets the list of methods in the class
Vi. Get_class (); Gets the class name instantiated by the object
Iv. Exception Handling:
A) try{
Detects an event that throws an exception if there is an exception (instantiates a system base class exception class and throws it to the variable behind the catch for storage!). This variable can contain all the accumulated methods! )
}catch (Exception $e) {
The error message corresponding to the exception in the try code!
$e->getmessage (); Get error message
$e->getcode (); Get error encoding
$e->getfile (); Get the absolute path to the error file
$e->getline (); Get the line number where the error line is located
}

1 //Exception Handling2 $b= 0;3 Try{4     if($b==0){5         Throw New Exception(' Sorry, the divisor cannot be 0 ', 101);//base class6     }7     $c= 100/$b;8     Echo $c;9}Catch(Exception $e){Ten  One     //The error in the try code is output here A     Echo $e->getmessage (). ' <br/> ';//get the error message!  -     Echo $e->getcode (). ' <br/> ';//Get error code -     Echo $e->getfile (). ' <br/> ';//gets the absolute path of the current error file the     Echo $e->getline (). ' <br/> ';//gets the line number of the current error line -  -}

"PHP" Object-oriented (v)

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.