3v4l.org

run code in 300+ PHP versions simultaneously
<?php // NO! /* <li<?php if (! has_post_thumbnail() ) { echo ' class="no-img"'; } ?>> <?php if ( has_post_thumbnail() ) { the_post_thumbnail('alm-thumbnail'); }?> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> </li> */ function the_title() { return 'A Title'; } function the_permalink() { return 'https://google.com'; } function has_post_thumbnail() { return true; } function the_post_thumbnail($whateverThisIs) { return '<img src="https://upload.wikimedia.org/wikipedia/en/2/22/Charlie_Brown.png" />'; } $imgClass = 'no-img'; $img = ''; $title = the_title(); $link = the_permalink(); if(has_post_thumbnail()) { $imgClass = ''; $img = the_post_thumbnail('alm-thumbnail'); } // look!!! here you can debug and check the values of $img and other things to check your logic etc //HTML output starts HERE: echo " <li class='${imgClass}'> ${img} <h3><a href='${link}'>${title}</a></h3> </li> "; // or other output idea
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/u7Olq on line 41 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/u7Olq on line 42 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/u7Olq on line 43 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/u7Olq on line 44 <li class=''> <img src="https://upload.wikimedia.org/wikipedia/en/2/22/Charlie_Brown.png" /> <h3><a href='https://google.com'>A Title</a></h3> </li>
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27
<li class=''> <img src="https://upload.wikimedia.org/wikipedia/en/2/22/Charlie_Brown.png" /> <h3><a href='https://google.com'>A Title</a></h3> </li>

preferences:
193.96 ms | 403 KiB | 283 Q