I am trying to echo two predefined variables, on the same line, with a space in between them. I am also hoping to use either ucfirst or ucwords to capitalize the first letter of each word. But to my understanding these only work with a string.

Here is the code I have:

<?php if(isset($_SESSION['uname'])){
		  echo ucwords$_SESSION['fname'] $_SESSION['lname'];
		  }?>

I can get it to work with one variable using:

echo ucfirst($_SESSION['fname']);

But I am not sure how to incorporate the second variable into the string and get the results I want. Will someone please help?

You use . to concatenate so echo ucwords($_SESSION['fname'] . ' ' . $_SESSION['lname']);

Thanks so much Shawn!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.