Page 1 of 1

PHP User defined function

Posted: Fri Aug 11, 2006 3:27 am
by sujithfem
hi

is there any way to inlude the userdefined function in to PHP predefined lib function ,please let me know the same ,advance thanks for valuable solution...

regards

Sujith

Posted: Fri Aug 11, 2006 3:29 am
by volka
please elaborate.

Posted: Fri Aug 11, 2006 3:36 am
by onion2k
create_function()

Posted: Fri Aug 11, 2006 3:44 am
by sujithfem
For example:
we have write different function in PHP.
I want to add this function in PHP lib. like (str_replace..)

Posted: Fri Aug 11, 2006 4:16 am
by Ollie Saunders
I think, but I cannot be certain that the answer you seek is unfortunately no.
To add to the PHP function library requires you to modify the C code that makes PHP, well PHP.

If this is indeed what you are asking, may I ask for what ends are you interested in this?

Posted: Fri Aug 11, 2006 4:34 am
by sujithfem
Ok I want custom function for my php software ,i think it like shell scripts in unix ..it's ok ,thanks for your reply

Posted: Fri Aug 11, 2006 4:44 am
by Ollie Saunders
Oh right! You really should look at the manual on functions

Code: Select all

function add($a, $b) {
    return $a + $b;
}

Posted: Fri Aug 11, 2006 7:00 am
by onion2k
You don't need to modify the PHP source to add your own functions to PHP's library. Just put them in a PHP file, defined as usual with function() { } blocks, and then use PHP's auto_prepend directive to include that file on every page.

http://www.zend.com/zend/spotlight/prepend.php

Posted: Fri Aug 11, 2006 7:42 am
by jamiel
Is this a function written in C? If so you will need to read up on extending the PHP Libraries.