php optional arguments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

andythepandy

Thread Starter
Joined
Jul 2, 2006
Messages
379
Hi all,
I have a function in a class that makes a connection to mysql:

Code:
public function Connect($server=$this->server, $username=$this->username,$password=$this->password)
The $server, $username and $password arguments are optional, as they are set with default values at the constructor, and I want the arguments to be equal to the variables defined in the constructor if they are not defined in the function call. The code above returns a parse error.

Any suggestions on how to do this?

Many thanks,
Andy
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top