Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics Getting to Know PHP Intro to Workspaces and PHP Code

Barak TheProgrammer
Barak TheProgrammer
1,773 Points

hey, im on php basics course with Alea Holligan.

my question is about the second's video teacher's notes, i didn't understand what does she mean over there. may someone will clear it for me please? thanks :)

1 Answer

Just note that it isn't that important.

It's just explaining that echo and print are a little bit different, because print returns the value 1 and echo doesn't return anything.

Just keep in mind to try to use echo and only use print when you really have to. The echo function/method is a little but faster and is used more often.

~Alex

Barak TheProgrammer
Barak TheProgrammer
1,773 Points

what does it mean "print return 1" cause as i get it print just need to output the text dont it?

The print function does print out the value of whatever you say, but it returns 1.

Returning a value isn't the same as printing a value :)

For example take a look at this:

<?php

    $someValue = print("Hi!");
    echo $someValue;

?>

The code above will print out:

Hi!
1

Anyway, you will learn more about functions and returning values in a future video :smile: