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

Link to comment
Share on other sites

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.";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.