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 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'); 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; ?> 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 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
Archived
This topic is now archived and is closed to further replies.