Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics Unit Converter Integers

2 Answers

Simon Coates
Simon Coates
28,694 Points

At a basic level, it's a sequence of characters (eg "this is a string literal"). see http://php.net/manual/en/language.types.string.php

String is sequence of characters

  • $fruit = 'Apple';
  • $vegetable = 'tomato';

For example you want to display it into list what you have bought

<ul>
   <li><?php echo $fruit; ></li>
   <li><?php echo $vegetable; ></li>
</ul>

In the real world solutions you will probably use some templating system.

If you are curious look at:

The first one is often used with symfony.

The second one with laravel and the last one with nette.

If you ask why to use f.e. twig, let me rewrite my example it would look like this:

<ul> 
   <li>{{ fruit }}</li>
   <li>{{ vegetable }}</li>
</ul>

It has specific syntax which helps you write more concise and readable code