Forum Moderators: coopster

Message Too Old, No Replies

Javascript to PHP

         

xize

12:47 pm on Oct 24, 2007 (gmt 0)

10+ Year Member



Anyone knows how to write this function in PHP?

function Substitute() {
var args=Substitute.arguments;
var Base=args[0];
}

I would appreciate for any help...

Habtom

12:55 pm on Oct 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't be sure on this one, but the following might be of some help:

function Substitute() {
var args=Substitute.arguments;
var Base=args[0];
}

Something like the following:

function Substitute(args) {
$Base = args[0];
. . .
}

xize

7:57 am on Oct 25, 2007 (gmt 0)

10+ Year Member



@ Habtom thanks for the reply and my apology for not giving the complete information on my issue.

So here it is, I was able to create it in Javascript but find difficulty in PHP. Supposing I have a function same as below but it will pass un-fixed number of values, depending on the users input. Sometimes it could only be one or two or three, so I cannot use the exact number of parameters.

function Substitute($args) {
$Base = $args[0];
}

Substitute($var1,$var2,$var3);

Habtom

8:07 am on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



so I cannot use the exact number of parameters

I am not sure if you can do that.

cameraman

8:17 am on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at func-get-args() [php.net]

Habtom

8:19 am on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmmm cameraman, I vaguely remember using the function once, but it is good you brought it up.

xize

8:28 am on Oct 25, 2007 (gmt 0)

10+ Year Member



Hi Habtom and Cameraman

I just came across the functions: func_num_args(), func_get_arg(), and func_get_args() and I am studying it right now.

Thank you for the help.