Jump to content

[SOLVED] string concat with number and operator?


DssTrainer

Recommended Posts

It seems almost silly that I'm unsure how to do this, but it left me with a confused look on my face.

 

If I do:

 

$i = 0;

$class = 'sub_cat_' . $i;

echo $class;

 

it shows

"sub_cat_0"

 

But, if I do:

$i = 0;

$class = 'sub_cat_' . ($i+1);

echo $class;

 

it just shows:

"1"

 

Why does it throw away the string if I am doing an equation after it?

 

 

Ah.. you know what.. i didn't have the parenthesis in there. I added those when I typed up this thread... It removes the string when i leave the parenthesis out. But you are right, as long as I have them in, it works.

 

Sorry.. I need more sleep :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.