jekillen | 1 Jan 2008 23:17
Picon

variable substitution

Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a  and
set $string_b  to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
"stuff and by the way; and more stuff"
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body -> !SPAM.

this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.

Q: Is there a way to get the substitution to take
     place here? (by reference, maybe?)

Thank you in advance for info
Jeff K

--

-- 
(Continue reading)

James Ausmus | 2 Jan 2008 00:48

Re: variable substitution

On Jan 1, 2008 2:17 PM, jekillen <jekillen <at> prodigy.net> wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a  and
> set $string_b  to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.

Several ways to do this (and avoid globals or a str_replace call):

#1:

if (condition)
{
  $string_b = 'blah';
} else if (condition2)
{
 $string_b = 'foo';
(Continue reading)

jekillen | 2 Jan 2008 01:06
Picon

Re: variable substitution


On Jan 1, 2008, at 3:48 PM, James Ausmus wrote:

> On Jan 1, 2008 2:17 PM, jekillen <jekillen <at> prodigy.net> wrote:
>> Hello again;
>> I have two variables declared in the global scope of a script.
>> $string_a = 'stuff $string_b and more stuff';
>> $string_b = '';
>> One is a string with a reference for substitution to the other
>> string which is empty.
>> In the processing body of the script are if/if else blocks.
>> In these blocks I want to use $string_a  and
>> set $string_b  to a value
>> if( condition)
>> { $string_b = 'by the way;';... etc
>> so $string_a should read:
>> "stuff and by the way; and more stuff"
>> But this substitution will not take place
>> in the context of the else if block. I do not
>> want to write $string_a in at least 5 different
>> if else blocks because it is about 10 lines
>> intended to be an e-mail message body -> !SPAM.
>
> Several ways to do this (and avoid globals or a str_replace call):
>
> #1:
>
> if (condition)
> {
>   $string_b = 'blah';
(Continue reading)

Richard Lynch | 2 Jan 2008 00:31

Re: variable substitution

On Tue, January 1, 2008 4:17 pm, jekillen wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a  and
> set $string_b  to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.
>
> this script is used to process data sent from a
> link in another e-mail message used to validate
> and e-mail address.
>
> Q: Is there a way to get the substitution to take
>      place here? (by reference, maybe?)

http://php.net/str_replace

--

-- 
(Continue reading)

jekillen | 2 Jan 2008 00:59
Picon

Re: variable substitution


On Jan 1, 2008, at 3:31 PM, Richard Lynch wrote:

> On Tue, January 1, 2008 4:17 pm, jekillen wrote:
>> Hello again;
>> I have two variables declared in the global scope of a script.
>> $string_a = 'stuff $string_b and more stuff';
>> $string_b = '';
>> One is a string with a reference for substitution to the other
>> string which is empty.
>> In the processing body of the script are if/if else blocks.
>> In these blocks I want to use $string_a  and
>> set $string_b  to a value
>> if( condition)
>> { $string_b = 'by the way;';... etc
>> so $string_a should read:
>> "stuff and by the way; and more stuff"
>> But this substitution will not take place
>> in the context of the else if block. I do not
>> want to write $string_a in at least 5 different
>> if else blocks because it is about 10 lines
>> intended to be an e-mail message body -> !SPAM.
>>
>> this script is used to process data sent from a
>> link in another e-mail message used to validate
>> and e-mail address.
>>
>> Q: Is there a way to get the substitution to take
>>      place here? (by reference, maybe?)
>
(Continue reading)

Casey | 1 Jan 2008 23:31
Picon

Re: variable substitution

On Jan 1, 2008 2:17 PM, jekillen <jekillen <at> prodigy.net> wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a  and
> set $string_b  to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.
>
> this script is used to process data sent from a
> link in another e-mail message used to validate
> and e-mail address.
>
> Q: Is there a way to get the substitution to take
>      place here? (by reference, maybe?)
>
> Thank you in advance for info
> Jeff K
>
(Continue reading)


Gmane