How do I display PHP code 02/13/11
As you probably recall in our previous article on php variables we used something called echo. Your entire PHP career will rely not only on your ability to create a script that produces a desired result, but to display that result to the web for the world to see. This is done through the echo command. <?php $myResult = ‘Hello’; echo $myResult; echo “<h3 class=\”className\”>This is fantastic</h3>”; ?> The above code will produce the following result: Hello This is fantastic In the above example, the text being displayed comes from a variable and straight HTML being echoed. You’ll notice I used a single quote for the first echo and a double quote for the second echo. Both will do the job, but you need to use the same quote on both ends. The single quote is helpful when you want to write HTML directly into. You’ll ...
Brandon Waring - Ma, Boston
Web Design: Web Design & SEO Company
As you probably recall in our previous article on php variables we used something called echo. Your entire PHP career will rely not only on your ability to create a script that produces a desired result, but to display that result to the web for the world to see. This is done through the echo command.
$myResult = ‘Hello’;
echo $myResult;
echo “<h3 class=\”className\”>This is fantastic</h3>”;
?>
The above code will produce the following result:
This is fantastic
In the above example, the text being displayed comes from a variable and straight HTML being echoed. You’ll notice I used a single quote for the first echo and a double quote for the second echo. Both will do the job, but you need to use the same quote on both ends. The single quote is helpful when you want to write HTML directly into. You’ll notice on the second echo example that I used a slash before the quotes on the class attribute. The slash tells PHP that you want to literally use the symbol for display, and not as part of your code.
echo ‘<a href=”http://mediamonstah.com”>Media Monster</a>’;
?>
Because I used the single quote to open and close the string being echoed, I don’t need to put the slash before the double quotes that define the href attribute.
Media Monster webdesign offers custom website design for all size businesses. Our full service website design company only hires exceptional website designers. Please contact us today at 978-921-0012 for your next web site design project.
Did you like this article? Share it with your networks!
Both comments and pings are currently closed.
