Re: simple function question.
| From: | pong-TC | Date: | Wed, 10 Apr 2002 14:33:01 +0000 |
| Subject: | Re: simple function question. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92396@lists.php.net to get a copy of this message | ||
jbearer@pittsburghlive.com writes:
>this is a very simple question. I'm trying to figure out if there is a
>one line way to do this:
>
>I want to pass a variable to the function only if it matches a certin
>value, I know I can do this:
>
>if($a=='H') my_function($bob,'Y');
>else my_function($bob);
You can do this
($a=='H') ? my_function($bob,'Y'): my_function($bob);
>
>
>but If it's possible I'd like to do it with one line something that I'd
>think it would be like this.
>
>my_function($bob,if($a=='H') return 'Y'; );
>
Also, if you change this
>if($a=='H') return 'Y'
to a function ie foo(a){
>if($a=='H') return 'Y'
;}. Then, put foo(a) in my_function, I think it would work.
Pong