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! While you're at it, check out some resources Treehouse students have shared here.

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 Functions Introducing Functions Introducing Functions

hello

i hate html

4 Answers

Alexander Rasmussen
Alexander Rasmussen
12,901 Points

I believe Hampton Paulk explain it very well in the PHP Functions course.

However, in a function you define something that you want to call or use at any time you want.

Example:

function NameOfFunction (x = 1) {
    echo "x is equal to 1"
} else {
  echo "x is not equal to 1"
}

Then you have defined your function. A very simple one. first you write function to tell the code that you want to run a function. Then you name the function. Then you can make a condition. in this case x = 1.

If x = 1, then if will echo out "x is equal to 1"

If x is not equal to 1 it will echo out "x is not equal to 1"

And you just decide x by typing whatever x is. So you could write x = 2 and then it would echo out the 'else'. which is "x is not equal to 1"

That is generally how functions work.

Can you introducing fuction to me ?

thanks alex :D

Nathaniel Lough
Nathaniel Lough
9,215 Points

Notice how many stickers he obtained since the beginner series.