Chetan Mahore Chetan Mahore - 2 months ago 16
PHP Question

div inside echo function

i have this

<?php
} // if ( $coupons )

do_action('st_after_coupon_listings');
echo wpcoupon_store()->get_extra_info();

wp_reset_postdata();
?>


and i want to
get_extra_info()
inside of
<div class="mydiv"></div>


I tried

echo "<div class="mydiv">;
echo wpcoupon_store()->get_extra_info();
echo "</div>";


but this did not work.

I am making mistakes somewhere in syntax, it would mean a lot if someone could help.

Answer

Yes, there is a syntax error, you missed a quote" replace the bottom code with

echo '<div class="mydiv">';
echo wpcoupon_store()->get_extra_info();
echo '</div>';

or if you wish to keep the outer quotes constant you could use

echo "<div class=\"mydiv\">";
echo wpcoupon_store()->get_extra_info();
echo "</div>";

but this is a bit harder to read