FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Taking parameters into functions
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Taking parameters into functions [message #175661 is a reply to message #175660] Sun, 16 October 2011 18:15 Go to previous messageGo to previous message
houghi is currently offline  houghi
Messages: 45
Registered: September 2011
Karma:
Member
Peter H. Coffin wrote:
> In addition to Jerry's method (which I agree is a bad idea, for the
> reasons he gives), you can also default $File in the function
> declaration and make the parameter optional

OK, Ik wil, look for a different solution.

Still interested in a solution.

> function write_fifo($data,$File = "test.txt") {

Earier on my page I already named $File. It would be strange to have to
do this twice or more times. If I change the file I would rather do it
in only one place instead of 2 or more.

>
> You can even acheive a level of portability by defaulting the setting of
> the parameter to a constant, like
>
> define ("fifoFile", "/path/to/default/fifo/file");
> ...
> function write_fifo($data,$File = fifoFile) {

Now this is usefull and I will look into it. As far as I can see I would
only need to do a define once and it will be used all over the place.
That is exactly what I want.

houghi
--
> Beware of he who would deny you access to information, <
> for in his heart he dreams himself your master. <
> Commissioner Pravin Lal: "U.N. Declaration of Rights" <
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Editing a combobox
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 01:56:01 GMT 2024

Total time taken to generate the page: 0.03819 seconds