Page 1 of 1
Output Shortcut
Posted: Mon May 29, 2006 3:16 pm
by r_barlow
Hey,
I'm new to PHP but have developed pages in other languages such as JSP.
I was wondering if PHP has a shortcut to insert output so you don't have to write <? echo (stuff); ?> all the time.
For example, in JSP you could either do:
<% out.println(x); %>
or
<%= x%>
Thanks
Posted: Mon May 29, 2006 3:22 pm
by Chris Corbyn
<?= $var ?>
But don't rely on it.... it requires servers to have short tags enabled in php.ini (which I believe is due to be removed in PHP6).
Posted: Mon May 29, 2006 3:33 pm
by r_barlow
Ahh ok thanks.. another question that is kind of related is I'm looping through database records and outputting for each record. When I look at the generated html, all the outputs from the echos are grouped together in one big paragraph. Is there a way to make the echo space down? (print vs. println in JSP)
Posted: Mon May 29, 2006 3:38 pm
by Chris Corbyn
r_barlow wrote:Ahh ok thanks.. another question that is kind of related is I'm looping through database records and outputting for each record. When I look at the generated html, all the outputs from the echos are grouped together in one big paragraph. Is there a way to make the echo space down? (print vs. println in JSP)
It's \r\n in windows (and just \r on a mac i think).
Quick function for it:
Code: Select all
function println($str)
{
echo $str."\n";
}
Posted: Mon May 29, 2006 4:05 pm
by r_barlow
Awesome.. thanks a lot!!