PHP multiline string with PHP
You don't need to output php
tags:
<?php if ( has_post_thumbnail() ) { echo '<div class="gridly-image"><a href="'. the_permalink() .'">'. the_post_thumbnail('summary-image', array('class' => 'overlay', 'title'=> the_title('Read Article ',' now',false) )) .'</a></div>'; } echo '<div class="date"> <span class="day">'. the_time('d') .'</span> <div class="holder"> <span class="month">'. the_time('M') .'</span> <span class="year">'. the_time('Y') .'</span> </div> </div>';?>
You cannot run PHP code within a string like that. It just doesn't work. As well, when you're "out" of PHP code (?>
), any text outside of the PHP blocks is considered output anyway, so there's no need for the echo
statement.
If you do need to do multiline output from with a chunk of PHP code, consider using a HEREDOC:
<?php$var = 'Howdy';echo <<<EOLThis is outputAnd this is a new lineblah blah blah and this following $var will actually say Howdy as welland now the output endsEOL;
Use Heredocs to output muli-line strings containing variables. The syntax is...
$string = <<<HEREDOC string stuff hereHEREDOC;
The "HEREDOC" part is like the quotes, and can be anything you want. The end tag must be the only thing on it's line i.e. no whitespace before or after, and must end in a colon. For more info check out the manual.