print variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
akashiraffee
Forum Newbie
Posts: 1
Joined: Wed Apr 28, 2010 3:52 pm

print variable

Post by akashiraffee »

Hi. I'm totally new to php but have done a lot of web-dev with perl mason, which works in a similar way.

I'm wondering about some "parallel functionality". In a mason file, you can include a variable like this:

Code: Select all

<p><%$var_name%></p>
Right now, with my complete ignorance of php, I having to do this:

Code: Select all

<p><?php printf("%s", $var_name) ?></p>
Which is a lot more long winded. Is there a simpler way to output a variable, al la the mason method?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: print variable

Post by Christopher »

Code: Select all

<p><?php echo $var_name) ?></p>
It is still a little longer. If really need shorter then use a template system (or deprecated short tags)
(#10850)
Post Reply