Jump to content

Combining basic text with variables?


Brandon_R

Recommended Posts

Hello guys im sorry i didnt explain fully.

 

$total['text'] = $another;

$total['text'] = 'Basic Text';

 

How about i go about writing them in 1 line?

 

$total['text'] = 'Basic Text' $another; doesnt work.

 

Thank You.

I know very basic questions but im kinda new to PHP

Brandon_R

oh ok

 

 

$total['text'] = "Basic Text" . $another;

 

or

 

$total['text'] = "Basic Text";

$total['text'] .= $another;

 

the dot is used to connect things into larger strings... "basic text" must always be in quotes while variables are normally outside of quotes.. you could do something like..

 

$num_dogs = 5;

echo "There are ". $num_dogs ." dogs in the park.";

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.