kevinritt Posted March 1, 2009 Share Posted March 1, 2009 Hi, How could I display (echo) this info on a webpage? I keep getting missing ':' or ':' errors <? echo 'Hello, ' .$_SESSION['username'] 'it is ' .date('F j, Y') 'and the time is ' .date('H:i:s'); ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/147389-solved-concatenate-text-and-variables-in-php/ Share on other sites More sharing options...
Philip Posted March 1, 2009 Share Posted March 1, 2009 A few ways: echo 'Hello, ' .$_SESSION['username']. 'it is ' .date('F j, Y'). 'and the time is ' .date('H:i:s'); echo 'Hello, ',$_SESSION['username'],'it is ',date('F j, Y'),'and the time is ',date('H:i:s'); echo "Hello, {$_SESSION['username']} it is ".date('F j, Y')."and the time is ".date('H:i:s'); Quote Link to comment https://forums.phpfreaks.com/topic/147389-solved-concatenate-text-and-variables-in-php/#findComment-773629 Share on other sites More sharing options...
daveoffy Posted March 1, 2009 Share Posted March 1, 2009 I would do this <?php $username = $_SESSION['username']; $date = date('F j, Y'); $time = date('H:I:S'); echo 'Hello, '.$username.' it is '.$date.' and the time is '.$time; ?> Quote Link to comment https://forums.phpfreaks.com/topic/147389-solved-concatenate-text-and-variables-in-php/#findComment-773630 Share on other sites More sharing options...
kevinritt Posted March 1, 2009 Author Share Posted March 1, 2009 Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/147389-solved-concatenate-text-and-variables-in-php/#findComment-773631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.