PHP: classkit_method_add - Manual in Deutsh
PHP: classkit_method_add - Manual in French
PHP: classkit_method_add - Manual in Polish

You Are At PHP: classkit_method_add - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

classkit_method_add

(PECL)

classkit_method_add -- Dynamically adds a new method to a given class

Description

bool classkit_method_add ( string classname, string methodname, string args, string code [, int flags] )

Warning

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

Parameters

classname

The class to which this method will be added

methodname

The name of the method to add

args

Comma-delimited list of arguments for the newly-created method

code

The code to be evaluated when methodname is called

flags

The type of method to create, can be CLASSKIT_ACC_PUBLIC, CLASSKIT_ACC_PROTECTED or CLASSKIT_ACC_PRIVATE

Note: This parameter is only used as of PHP 5, because, prior to this, all methods were public.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example 1. classkit_method_add() example

<?php
class Example {
    function
foo() {
        echo
"foo!\n";
    }
}

// create an Example object
$e = new Example();

// Add a new public method
classkit_method_add(
    
'Example',
    
'add',
    
'$num1, $num2',
    
'return $num1 + $num2;',
    
CLASSKIT_ACC_PUBLIC
);

// add 12 + 4
echo $e->add(12, 4);
?>

The above example will output:

16

See Also

classkit_method_copy()
classkit_method_redefine()
classkit_method_remove()
classkit_method_rename()
create_function()

Wyjatkowej jakości meble medyczne w xmebel
Kotły gazowe
Grzejniki
zespół weselny warszawa
Największa baza pytań egzamin doradca podatkowy testy na doradce podatkowego

Another Useful functions:


zend-macro.z-obj-class-name-p | zend-api.zend-update-class-constants | zend-api.zend-u-lookup-class | zend-api.zend-u-lookup-class-ex | zend-api.zend-u-fetch-class | zend-api.zend-register-internal-class | zend-api.zend-register-internal-class-ex | zend-api.zend-register-default-classes | zend-api.zend-lookup-class | zend-api.zend-initialize-class-data | zend-api.zend-get-object-classname | zend-api.zend-get-class-entry | zend-api.zend-fetch-class | zend-api.zend-disable-class | zend-api.zend-declare-class-constant | zend-api.zend-declare-class-constant-stringl | zend-api.zend-declare-class-constant-string | zend-api.zend-declare-class-constant-long | zend-api.zend-declare-class-constant-double | zend-api.zend-declare-class-constant-bool | zend-api.zend-cleanup-class-data | zend-api.zend-class-implements | zend-api.get-active-class-name | zend-api.do-bind-inherited-class | zend-api.do-bind-class | zend-api.destroy-zend-class | reserved.classes | ref.classobj | ref.classkit | migration52.classes | migration52.class-constants | function.spl-classes | function.soap-soapserver-setclass | function.runkit-class-emancipate | function.runkit-class-adopt | function.mcal-event-set-class | function.is-subclass-of | function.get-parent-class | function.get-declared-classes | function.get-class | function.get-class-vars | function.get-class-methods | function.dom-domdocument-registernodeclass | function.classkit-method-rename | function.classkit-method-remove | function.classkit-method-redefine | function.classkit-method-copy | function.classkit-method-add | function.classkit-import | function.class-parents | function.class-implements | function.class-exists | function.bcompiler-write-class | function.bcompiler-parse-class | | class.variant | class.dotnet | class.dir | class.com |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.