Page 1 of 3

adding functions into php

Posted: Fri Aug 06, 2004 7:40 pm
by marker5a
Ok
I just recently discovered how functions work, and man are they great. My question is, instead of having to add

Code: Select all

<?php
function name(){blah blah}
?>
into all of my scripts, is there a way to actually integrate these into the php language itself? In other workds, is there a way to call the function from the script, without actually creating the function in the script itself? Right now, I have a file that contains all of my functions, and at the beginning of my script, i do an 'include' and that incorporates all of the functions into the script. Anyways, please help

Chris

Posted: Fri Aug 06, 2004 7:43 pm
by feyd
either [php_man]include[/php_man], or create your own extension for the functions you wish to have.

Posted: Fri Aug 06, 2004 7:43 pm
by Joe
When you say:
In other workds, is there a way to call the function from the script, without actually creating the function in the script itself
then you say:
i do an 'include' and that incorporates all of the functions into the script.
Is this not what you are asking for, or are you asking to call the functions from the actual script itself rather than an external one?

Posted: Fri Aug 06, 2004 7:53 pm
by marker5a
I think what feyd said, creating my own extensions is what I am talking about. Here is an example of what I mean. someone can call the substr command without setting up the function in the script, so I would like to make it so my own functions can just be called from the script. Does that help?

Chris

Posted: Fri Aug 06, 2004 7:55 pm
by Joe
Yes I get you now. Say the external script was "script.php" just use:

Code: Select all

include("script.php");

Posted: Fri Aug 06, 2004 7:56 pm
by marker5a
Joe, what I said earlier was that I was using the include, but I wanted to make it so I didnt. Sorry, I know this may be kind of confusing.

CHris

Posted: Fri Aug 06, 2004 7:59 pm
by Joe
require can also be used :D

Posted: Fri Aug 06, 2004 8:00 pm
by marker5a
Joe, I see what you are saying, but I think what feyd was saying earlier was hitting dead on. Don't get me wrong, I appreciate your help, but I think feyd knows what I am talking about.

Chris

Posted: Fri Aug 06, 2004 8:09 pm
by Joe
Chris,

feyd is giving exactly what I gave, he wrote:
either include
???

Posted: Fri Aug 06, 2004 8:22 pm
by marker5a
Ok
Im gonna keep sayiong this until one way sounds right. I would like to make it so that I can add functions into php itself. When you download php, it comes with tons and tons of functions, but I want to know how I can add my own to the mix, without creating php files with all of these functions in them.

CHris

Posted: Fri Aug 06, 2004 9:49 pm
by feyd
information on creating extensions: http://www.php.net/manual/en/zend.creating.php

Posted: Fri Aug 06, 2004 9:56 pm
by Joe
OK Well I guess I was way off, lol

Posted: Sat Aug 07, 2004 9:50 am
by marker5a
well, Feyd and Joe, thanks for the help. I really appreciate it. Im gonna see if I can make some sense out of this from the php site, and if I dont, you know I'll be back. Thanks again

Chris

Posted: Sat Aug 07, 2004 9:59 am
by d3ad1ysp0rk
Joe wrote:OK Well I guess I was way off, lol
yup ;)
:P

Posted: Sat Aug 07, 2004 10:06 am
by Joe
Yup indeed hehe, I was thinking of something totally different when I wrote that last night!