rubahfgouveia Posted February 7, 2012 Share Posted February 7, 2012 Hey guys, I'm trying to echo the following DIV: echo '<div class="event3" style="width:' $test[0] ' ">;' where $test[0] is a certain value (200 , 400 , etc), but it's not working.. Does anyone know how to I call the variable inside the DIV? Thanks alot, Rúben Gouveia Link to comment https://forums.phpfreaks.com/topic/256617-php-echo/ Share on other sites More sharing options...
The Little Guy Posted February 7, 2012 Share Posted February 7, 2012 I looks like it is because you are NOT concatenating $test[0] to the string, and your semi colon is inside the echo. echo '<div class="event3" style="width:' . $test[0] . ' ">'; personally, when working with HTML I use HEREDOC echo <<<OPT <div class="event3" style="width:{$test[0]}"> OPT; // The above line (OPT;) MUSTS be all the way to the left with no trailing data // the first line must also have no trailing data Link to comment https://forums.phpfreaks.com/topic/256617-php-echo/#findComment-1315528 Share on other sites More sharing options...
rubahfgouveia Posted February 7, 2012 Author Share Posted February 7, 2012 It worked like a charm! p.s: I've looked into heredoc, and it seems much more practical . Thanks mate! Link to comment https://forums.phpfreaks.com/topic/256617-php-echo/#findComment-1315539 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.