Echo: Class, Style and php -
i have these 3 strings need convert php can echo them. strings little complex me write out in straight php wondering if give me example of how below.
you don't have use code if don't want to, example on how can echo out these lines html class, style , embedded php sufficient.
this 1st one.
original:
<div class="newsdate" style="margin: 10px 0 !important;"><?= date("f d, y", strtotime($r['date'])); ?></div>
this tried getting confused in syntax:
echo "<div class='newsdate' style='margin: 10px 0 !important;'>"."date('f d, y', strtotime($r[date])).'</div>";
2nd one (little more complex me)
original:
<div class="articletext"><style>.articletext img{width:100%; height:auto;}</style><?php $string = $r[3]; $max = 300; // or 200, or whatever if(strlen($string) > $max) { // find last space < $max: $shorter = substr($string, 0, $max+1); $string = substr($string, 0, strrpos($shorter, ' ')).'...'; } echo $string; ?></div>
what have tried:
echo "<div class='articletext'>" . "<style>.articletext img{width:100%; height:auto;}</style>';" . " $string = $r[3];" . " $max = 300;" . " if(strlen($string) > $max) { < $max: $shorter = substr($string, 0, $max+1);" . " $string = substr($string, 0, strrpos($shorter, ' ')).'...';" . " } $string.'</div>";
3rd one.
original
<div class="btn small green white-tx"><a href="http://<?php echo $_server['server_name']; ?>/htp-news.php?id=<?=$r[0] ?>">continue reading</a></div>
what have tried:
echo "<div class='btn small green white-tx'>"." <a href='http://'.$_server['server_name'].'/htp-news.php?id='.$r[0].''>"."continue reading</a> </div>"
i appreciate help.
for 1st 1 try :
echo "<div class='newsdate' style='margin: 10px 0 !important;'>".date('f d, y', strtotime($r[date]))."</div>";
for 2nd try this:
echo "<div class='articletext'> <style>.articletext img{width:100%; height:auto;}</style>"; $string = $r[3]; $max = 300; if(strlen($string) > $max) { $shorter = substr($string, 0, $max+1); $string = substr($string, 0, strrpos($shorter, ' '))."..."; } echo $string."</div>";
and 3rd try:
echo "<div class='btn small green white-tx'> <a href='http://".$_server['server_name']."/htp-news.php?id=".$r[0]."'>continue reading</a> </div>";
Comments
Post a Comment