Re: [PHP] how do i give optional arguments to functions??

2001-10-25 Thread Jason G.

Umm...

function top($image = '')
{
 echo(bla bla $image bla);
}

Might need to use an IF (because of having 2 spaces if the image is empty)

-Jason Garber
IonZoft.com


At 10:14 AM 10/24/2001 -0700, Richard S. Crawford wrote:
function top ($image) {
 if ($image) echo blah blah blah;
 else echo blah blah $image blah;
}

There's probably a more efficient way to do it.


At 09:57 AM 10/24/2001, sunny AT wde wrote:
hi all!!

i'm writing functions like -
---
function top () {
  echo blah blah blah;}
---

what i want to do is make it so that i can do -
---
function top($image) {
  echo blah blah $image blah; }
---

but also make the $image parameter in the top() as optional. so if
its not there, then tell php not to worry about it.

any ideas??

thanks!

sunny


__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Sliante,
Richard S. Crawford

http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
It is only with the heart that we see rightly; what is essential is 
invisible to the eye.  --Antoine de Saint Exupéry

Push the button, Max!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] how do i give optional arguments to functions??

2001-10-24 Thread sunny AT wde

hi all!!

i'm writing functions like - 
---
function top () {
 echo blah blah blah;}
---

what i want to do is make it so that i can do - 
---
function top($image) {
 echo blah blah $image blah; }
---

but also make the $image parameter in the top() as optional. so if
its not there, then tell php not to worry about it.

any ideas??

thanks!

sunny


__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Richard S. Crawford

function top ($image) {
 if ($image) echo blah blah blah;
 else echo blah blah $image blah;
}

There's probably a more efficient way to do it.


At 09:57 AM 10/24/2001, sunny AT wde wrote:
hi all!!

i'm writing functions like -
---
function top () {
  echo blah blah blah;}
---

what i want to do is make it so that i can do -
---
function top($image) {
  echo blah blah $image blah; }
---

but also make the $image parameter in the top() as optional. so if
its not there, then tell php not to worry about it.

any ideas??

thanks!

sunny


__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Sliante,
Richard S. Crawford

http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
It is only with the heart that we see rightly; what is essential is 
invisible to the eye.  --Antoine de Saint Exupéry

Push the button, Max!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Arpad Tamas

On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:

The default value for $image parameter was missing:

 function top ($image=defaultvalue) {
  if ($image==defaultvalue) echo blah blah blah;
  else echo blah blah $image blah;
 }

Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Richard S. Crawford

Hm, is the default attribute necessary?  I've used this sort of approach 
without the default attribute just fine in the past.  Though I admit that 
the default attribute would make me feel more secure.


At 10:30 AM 10/24/2001, Arpad Tamas wrote:
On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:

The default value for $image parameter was missing:

  function top ($image=defaultvalue) {
   if ($image==defaultvalue) echo blah blah blah;
   else echo blah blah $image blah;
  }
 
 Arpi

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Sliante,
Richard S. Crawford

http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
It is only with the heart that we see rightly; what is essential is 
invisible to the eye.  --Antoine de Saint Exupéry

Push the button, Max!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Tamas Arpad

On Wednesday 24 October 2001 19:26, Richard S. Crawford wrote:
 Hm, is the default attribute necessary?  I've used this sort of
 approach without the default attribute just fine in the past. 
 Though I admit that the default attribute would make me feel more
 secure.

Not really necessary, but I like to make code without any warning 
message (it also makes the code more cleaner as you said), and you'll 
get a warning message if there's no parameter given at the function 
call (without the default value). 
Arpi


 At 10:30 AM 10/24/2001, Arpad Tamas wrote:
 On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:
 
 The default value for $image parameter was missing:
   function top ($image=defaultvalue) {
if ($image==defaultvalue) echo blah blah blah;
else echo blah blah $image blah;
   }
 
  Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Chris Bailey

Check out the manual section on default parameters...

But the basics are:

function top($image = null) {
if ($image) 
...
else
...
}

Or maybe:

That will set image to be null, so that you can call top either as:

top();
or
top($someimage);


-Original Message-
From: sunny AT wde [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 24, 2001 9:58 AM
To: php
Subject: [PHP] how do i give optional arguments to functions??


hi all!!

i'm writing functions like - 
---
function top () {
 echo blah blah blah;}
---

what i want to do is make it so that i can do - 
---
function top($image) {
 echo blah blah $image blah; }
---

but also make the $image parameter in the top() as optional. so if
its not there, then tell php not to worry about it.

any ideas??

thanks!

sunny


__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Richard S. Crawford

Ahh, good point.  Thanks for the tip.  :)


At 10:45 AM 10/24/2001, Tamas Arpad wrote:
Not really necessary, but I like to make code without any warning
message (it also makes the code more cleaner as you said), and you'll
get a warning message if there's no parameter given at the function
call (without the default value).
 Arpi


Sliante,
Richard S. Crawford

http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
It is only with the heart that we see rightly; what is essential is 
invisible to the eye.  --Antoine de Saint Exupéry

Push the button, Max!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread DL Neil

 On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:
 
 The default value for $image parameter was missing:
 
  function top ($image=defaultvalue) {
   if ($image==defaultvalue) echo blah blah blah;
   else echo blah blah $image blah;
  }

If the default value can be set to an empty string can the if statement then be 
removed?

   function top ($image=)
   {
  echo blah blah $image blah;
   }

- watch those spaces (if they're present in live data)!
=dn



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Chris Bailey

It could be, but then you would have two spaces in between the 2nd and 3rd
blah, instead of just the one space.  But, depending on your actual
application, this may work out.

-Original Message-
From: DL Neil [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 24, 2001 10:41 AM
To: Arpad Tamas; Richard S. Crawford; sunny AT wde; php
Subject: Re: [PHP] how do i give optional arguments to functions??


 On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:

 The default value for $image parameter was missing:

  function top ($image=defaultvalue) {
   if ($image==defaultvalue) echo blah blah blah;
   else echo blah blah $image blah;
  }

If the default value can be set to an empty string can the if statement then
be removed?

   function top ($image=)
   {
  echo blah blah $image blah;
   }

- watch those spaces (if they're present in live data)!
=dn



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Mike Frazer

Don't forget: if a function has multiple arguments the optional ones must be
to the RIGHT of the required ones:

function testing123($one, $two=2, $three=3)// Good
function testing123($one=1, $two, $three=3)// Bad
function testing123($one=1, $two=2, $three)// Bad

Mike Frazer



Chris Bailey [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 It could be, but then you would have two spaces in between the 2nd and 3rd
 blah, instead of just the one space.  But, depending on your actual
 application, this may work out.

 -Original Message-
 From: DL Neil [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, October 24, 2001 10:41 AM
 To: Arpad Tamas; Richard S. Crawford; sunny AT wde; php
 Subject: Re: [PHP] how do i give optional arguments to functions??


  On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote:
 
  The default value for $image parameter was missing:
 
   function top ($image=defaultvalue) {
if ($image==defaultvalue) echo blah blah blah;
else echo blah blah $image blah;
   }

 If the default value can be set to an empty string can the if statement
then
 be removed?

function top ($image=)
{
   echo blah blah $image blah;
}

 - watch those spaces (if they're present in live data)!
 =dn



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread John A. Grant

Chris Bailey [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Check out the manual section on default parameters...

 But the basics are:

 function top($image = null) {
 if ($image)

Shouldn't that be:

function top($image=null)
if ($image)

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] how do i give optional arguments to functions??

2001-10-24 Thread Chris Bailey

Yes, it definitely should :)  Heh, I think I originally had , but then new
that'd result with the double space problem, so changed it.  My bad.

-Original Message-
From: John A. Grant [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 24, 2001 1:28 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] how do i give optional arguments to functions??


Chris Bailey [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Check out the manual section on default parameters...

 But the basics are:

 function top($image = null) {
 if ($image)

Shouldn't that be:

function top($image=null)
if ($image)

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]