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

WordPress

Don Shipley
Don Shipley
19,488 Points

What is concatenate?

Inside of the my_plugin_get_profile function, create a variable named "json_feed_url" that concatenates the domain name http://myapi.net with the my_plugin_username variable and appends ".json" to the end.

4 Answers

The question is asked correctly. It's asking you to concatenate (link together/combine) the domain name with $my_plugin_username and then add '.json' to the end, which looks like this: 'http://myapi.net/' . $my_plugin_username . '.json'. It then wants you to assign that code to $json_feed_url. I agree that the wording is slightly confusing, but it is worded correctly.

Leroy Sibisi
Leroy Sibisi
20,619 Points

Hi,

I tried your method, but it is not passing.

function my_plugin_get_profile($my_plugin_username) { $json_feed_url = 'http://myapi.net'.'my_plugin_username'.'json'; }

Hey Leroy Sibisi! You're pretty close! Take a closer look at what you are assigning to $json_feed_url. You're concatenating three strings: 'http://myapi.net', 'my_plugin_username', and 'json'. Remember we want $json_feed_url to be equal to a url of the form "http://myapi.net/MikeTheFrog.json", for example, if "MikeTheFrog" is passed into the function. So you would want to concatenate the string 'http://myapi.net/' (don't forget the last slash "/"!), the variable $my_plugin_username (not a string!), and the string '.json' (don't forget the dot in front "."!). Hope that helps! :)

Leroy Sibisi
Leroy Sibisi
20,619 Points

Thank you very much Kristen. I passed the challenge!

Andres Ramirez
Andres Ramirez
18,094 Points
<?php
function my_plugin_get_profile($my_plugin_username) { 
  $json_feed_url = 'http://myapi.net/'.$my_plugin_username.'.json'; 
}
?>

This got mine to pass:

function my_plugin_get_profile($my_plugin_username){ $json_feed_url = '"http://myapi.net" . {$my_plugin_username} . ".json"'; }

And then I saw that I didn't have the "/" after .net . It does need that, so I'm not sure why it let my code through!