Re: The default values of variables in a function
| From: | Teodor Cimpoesu | Date: | Mon, 25 Sep 2000 07:40:43 +0000 |
| Subject: | Re: The default values of variables in a function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17414@lists.php.net to get a copy of this message | ||
Hi Matt!
On Thu, 21 Sep 2000, Matt wrote:
> I'm trying to set a default value for a variable in a php function. See
> function below.
> With the following, it gives me an error because I'm using a variable:
>
> function RunQuery($sql,$datasource=$app_mySQL_DSN)
>
> if I change it to this, it works:
>
> function RunQuery($sql,$datasource="theDSN")
>
> Any ideas as to my this is happening or if there is a work around?
I assume you are using PHP4, as this used to work in PHP3.
This is one of the imcompatibilities from 3->4.
You may define('SOMETHING') and use FuntionFoo ($par = SOMETHING);
-- teodor