Forum Moderators: coopster
I have made a few functions that I use on almost all my websites. I am thinking if there is a way to put these functions somewhere on the server so that they become like normal php functions(strpos,nl2br etc)
I think it should be possible, I will be thankful for any hint on that.
thanks
bye
[edited by: Jaunty_Edward at 1:53 am (utc) on Mar. 30, 2007]
Good luck!
and I just have to add the following line in php.ini
auto_append_file('www.example.com/phpfunctions.php');
and it will start working on all domains on the server.
wondering if we will be able to refer phpfunctions.php file that way or will we have to put it in the php dir?
I will confirm this once I am done with it.
anyone has any other suggestions.
thanks
bye
[edited by: dreamcatcher at 7:25 am (utc) on Mar. 30, 2007]
[edit reason] Use example.com, thanks. [/edit]
auto_append_file('www.example.com/phpfunctions.php');
The syntax in php.ini is
auto_prepend_file [i]string[/i]
Where string is the path to the file. Don't use a uri for the path because it will not be included as a php script, but rather the output from that script. Instead, refer to it using a relative path.
Henry, yes it will work with classes as well. It is the same thing as calling an include [php.net] at the beginning at every file, you just don't have to key it in every time.
I've been looking at some of the c that revolves around php and its pretty neat stuff. I never had the need to make my own extension, although it must feel like a great achievement. :)
I am wondering how do extension behave? I guess they are only loaded if the functions are called.
Will it make a heavy impact on the performance of website? Considering around 2 Million page views a month across all sites on the server.
thanks
bye
If you aren't going to be using those functions over and over again, then it would be best to just use include() to get the function definitions before you use them in each script. It will make it more like working with c, where you have to "include" the libraries you want to work with before you can use them.
Here is what I have done:
created a function and saved the file as myfunc.php I also moved the file to c:/php/includes folder.
edited 2 lines in my php.ini file:
include_path = ".;c:\php\includes"
auto_append_file = myfunc.php
but when I try to use the function, its giving me Fatal error: Call to undefined function: testfunc()
I dont know how to set proper values in php.ini
please help
thanks
bye
[edited by: Jaunty_Edward at 1:24 am (utc) on Mar. 31, 2007]