/    Sign up×
Community /Pin to ProfileBookmark

echo two variables on the one line

Hi, i have a page that echoes my username at the top of the page, however i want to change it to [B]firstname[/B] [B]lastname[/B]

At the top of the page the following code appears:

<? echo $_SESSION[‘user_info’][‘username’];?>

however my firstname and lastname are the following variables. How do output the two of these with just the one echo

firstname = [B]$_SESSION[‘my_array’][1][/B]
lastname = [B]$_
SESSION[‘my_array’][12][/B]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Oct 01.2007 — [code=php]
echo $_SESSION['my_array'][1] . " " . $_SESSION['my_array'][12];
[/code]
Copy linkTweet thisAlerts:
@oo7mlauthorOct 01.2007 — should there be single or double quotes between them
Copy linkTweet thisAlerts:
@NightShift58Oct 01.2007 — You choose:

single quote - space - single quote

or

double quote - space - double quote
Copy linkTweet thisAlerts:
@oo7mlauthorOct 01.2007 — Ok, thanks for your help
Copy linkTweet thisAlerts:
@NightShift58Oct 01.2007 — Welcome, sir.
Copy linkTweet thisAlerts:
@MrCoderOct 01.2007 — You should always use double quotes for static strings since they are parsed much faster within PHP.
Copy linkTweet thisAlerts:
@NightShift58Oct 01.2007 — I believe the opposite is true.

If PHP sees single quotes, it knows the string is static and it uses verbatim without further ado. If it sees double quotes, it has to parse to ensure that no variables are embedded.

Having said that, some months NogDog ran a test with 100K loops and while the single quotes were faster, the difference was, for all practical purposes, negligible.

So... you choose, Mr. Coder...
Copy linkTweet thisAlerts:
@MrCoderOct 01.2007 — I knew that would rattle your cage ?

Its good having you back ?


http://www.webdeveloper.com/forum/showthread.php?t=161577
Copy linkTweet thisAlerts:
@NightShift58Oct 02.2007 — At 4:25 a.m., nothing was rattling... call it reflex...
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...