PHP User defined function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sujithfem
Forum Newbie
Posts: 23
Joined: Tue May 23, 2006 10:56 pm
Location: India
Contact:

PHP User defined function

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please elaborate.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

create_function()
sujithfem
Forum Newbie
Posts: 23
Joined: Tue May 23, 2006 10:56 pm
Location: India
Contact:

Post by sujithfem »

For example:
we have write different function in PHP.
I want to add this function in PHP lib. like (str_replace..)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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?
sujithfem
Forum Newbie
Posts: 23
Joined: Tue May 23, 2006 10:56 pm
Location: India
Contact:

Post 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
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Oh right! You really should look at the manual on functions

Code: Select all

function add($a, $b) {
    return $a + $b;
}
Last edited by Ollie Saunders on Fri Aug 11, 2006 7:06 am, edited 1 time in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

Is this a function written in C? If so you will need to read up on extending the PHP Libraries.
Post Reply