php (grammar) Magic Functions and Variables

2010-03-29  来源:本站原创  分类:PHP  人气:190 

1: Magic function

__construct ()

Instantiated object is called.

When the __construct and in class while the function called function name exists, __construct is called, the other not to be called.

__destruct ()

When you remove an object or object is called when the operation terminated.

__call () object called a method,

If the method exists, a direct call; if there will be to call the __call function.

__get () to read an object's attributes.

If the property exists, the direct return property values; if there will be call the __get function.

__set () to set an object property.

If the property exists, the direct assignment; if there will be calls __set function.

__toString ()

When printing an object is called. If echo $ obj; or print $ obj;

__clone ()

Cloned object is invoked. Such as: $ t = new Test (); $ t1 = clone $ t;

__sleep ()

be called before serialize. If the object larger, to cut a little stuff and then serialized, can consider this function.

__wakeup ()

unserialize when called, do object initialization.

__isset ()

Detect the existence of the properties of an object when called. Such as: isset ($ c-> name).

__unset ()

unset attribute of an object is called. Such as: unset ($ c-> name).

__set_state ()

Call var_export, they were called. The return value with __set_state as var_export the return value.

__autoload ()

Instance of an object, if the corresponding class does not exist, then the method is called.

2: Magic variable

__LINE__

Back to document the current line number.

__FILE__

Back to document the full path and file name. If the included file is returned that contains the file name. Starting from PHP 4.0.2, __FILE__ always contains an absolute path, in which the previous version sometimes includes a relative path.

__FUNCTION__

Return the function name (PHP4.3.0 added). Since PHP5 from this constant returns the function is defined by the name (case sensitive). In PHP4, the value is always lower case letters.

__CLASS__

Back to the class name (PHP4.3.0 added). Since PHP5 from the constant returns the class is defined by the name (case sensitive). In PHP4, the value is always lower case letters.

__METHOD__

Back to class method names (PHP5.0.0 added). Return the method is defined by the name (case sensitive).

相关文章
  • php (grammar) Magic Functions and Variables 2010-03-29

    1: Magic function __construct () Instantiated object is called. When the __construct and in class while the function called function name exists, __construct is called, the other not to be called. __destruct () When you remove an object or object is

  • php magic functions and Magic constants 2011-04-18

    1. __construct () Instantiated object is called, when the __construct function name and the class name of the function also exist, __construct is called, and the other is not called. 2. __destruct () When you remove an object or object is called when

  • php functions and variables preceded by ampersand symbol in front of the significance of Canada & 2010-04-25

    php function preceded by & symbol means the function returns a reference, php function add & symbol in front of what use it function &test() { static $b=0;// Declare a static variable $b=$b+1; echo $b; return $b; } $a=test();// This statement

  • php magic magic methods and variables 2010-11-30

    PHP all by __ (two underscores) at the beginning of the class method as a magic method. So you define your own class method, do not be prefixed with __. 1, __construct () When instantiating an object, the object's constructor will be called first; Ph

  • php in this keyword:: Symbol magic method 2010-04-30

    We all know that in php or other languages, this means the current object itself, we can easily reference some of its properties approach Sometimes, in the absence of any instances where access to the class of functions or base classes useful functio

  • Eclipse plug-ins to use Ruby Development Tools 2009-09-09

    Eclipse plug-ins to use Ruby Development Tools Document options Send as an e-mail this page Tomcat Application Development Download IBM open-source J2EE application server, WAS CE new version V1.1 Level: Intermediate Neal Ford ( neal.ford @ gmail.com

  • MyEclipse shortcut keys 2010-03-29

    MyEclipse shortcut keys Da Quan (1) Ctrl + M to switch the window size (2) Ctrl + Q jump to the last editorial services (3) F2 when the mouse over a marker Tooltip occurred at the time put the mouse away by F2 when the Tooltip also shows that the Sho

  • Eclipse Shortcuts Daquan 2010-03-29

    The end of technology: Ctrl + Shift + L Show all quick fix shortcut Ctrl +1 (the most classic of the shortcut keys, it goes without saying that a) Ctrl + D: delete the current line Ctrl + Alt + ↓ to copy the current line to the next line (reproductio

  • eclipse shortcut keys Daquan 2010-03-29

    me [email protected] Quick Fix Ctrl +1 (the most classic of the shortcut keys, you need not) Universal access keys Ctrl +3 Ctrl + D: delete the current row Ctrl + Shift + L Show shortcut keys Ctrl + Alt + ↓ to copy the current line to the next li

  • eclipse shortcut keys 2010-03-29

    Ctrl+1 Quick Fix ( The most classic keyboard shortcuts , Needless to say the on ) Ctrl+D: Delete the current row Ctrl+Alt+ ↓ copy the current line to next line ( Reproduction, ) Ctrl+Alt+ ↑ copy the current line to previous line ( Reproduction, ) Alt

  • MyEclipse shortcut keys Daquan 2010-03-29

    MyEclipse shortcut keys (1) Ctrl + M to switch the window size (2) Ctrl + Q jump to the last editorial services (3) F2 when the mouse over a marker occurring at the Tooltip press F2 when the Tooltip is also when you put the mouse away will show that

  • MyEclipse shortcut keys Daquan (reproduced) 2010-03-29

    MyEclipse shortcut keys (1) Ctrl + M to switch the window size (2) Ctrl + Q jump to the last editorial services (3) F2 when the mouse over a marker occurring at the Tooltip press F2 when the Tooltip is also when you put the mouse away will show that

  • Use a shortcut to Eclipse 2010-03-29

    1. Ctrl + Left This is the most frequently used, is used to view variables, methods, class definitions 2. Ctrl + O See a class outline, listing its methods and member variables. Tip: more time I press the Ctrl + O, can list the class inherits methods

  • Eclipse shortcut keys Daquan (reproduced) 2010-04-16

    Quick Fix Ctrl +1 (the most classic of the shortcut keys, you need not) Ctrl + D: delete the current row Ctrl + Alt + ↓ to copy the current line to the next line (copy increase) Ctrl + Alt + ↑ copy the current line to the previous row (copy increase)

  • eclipse.myeclipse commonly used shortcuts 2009-08-18

    Common MyEclipse shortcut keys 2008-07-19 11:19 I have verified that the shortcut keys are available plus some red (MyEclipse 6 below): Automatic typesetting code: Ctrl + Shift + F, will automatically format the code layout is very convenient Format

  • MyEclipse 7.0 shortcut keys Daquan [reproduced] 2008-05-07

    Common keyboard shortcuts eclipse 1. 【ALT + /】 The shortcut keys for the user to edit a good helper, can provide users with the content of assistance, not to memorize methods and attribute names anxious, when the mind incomplete classes, methods, and

  • Classic Collection standby shortcut keys eclipse 2009-08-07

    Save Ctrl + s (surely know) Note the code Ctrl + / Uncomment the Ctrl + \ (Eclipse3 have all merged into the Ctrl + / a) Code-assisted Alt + / Quick Fix Ctrl +1 Code formatting Ctrl + Shift + f Finishing Import Ctrl + Shift + o Switching window Ctrl

  • Eclipse shortcut keys Daquan (change) 2010-03-22

    Quick Fix Ctrl +1 (the most classic of the shortcut keys, you need not) Ctrl + D: delete the current row Ctrl + Alt + ↓ to copy the current line to the next line (copy increase) Ctrl + Alt + ↑ copy the current line to the previous row (copy increase)

  • Eclipse shortcut keys (Reprinted) 2010-03-31

    Quick Fix Ctrl +1 (the most classic shortcuts need add nothing) Ctrl + D: delete the current row Ctrl + Alt + ↓ to copy the current line to the next line (copy increase) Ctrl + Alt + ↑ copy the current line to the line (copy increase) Alt + ↓ current

  • Eclipse commonly used shortcut keys (reprint) 2010-03-31

    Quick Fix Ctrl +1 (the most classic shortcuts need add nothing) Ctrl + D: delete the current row Ctrl + Alt + ↓ to copy the current line to the next line (copy increase) Ctrl + Alt + ↑ copy the current line to the line (copy increase) Alt + ↓ current