FAQ: Intro to Built-in PHP Functions - Number Functions

This community-built FAQ covers the “Number Functions” exercise from the lesson “Intro to Built-in PHP Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn PHP

FAQs on the exercise Number Functions

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

My only comment to fellow noobs, Google is your friend. Personally, I don’t believe the program did the best job explaining the syntax of custom functions. As a result, it took some experimenting to understand passing an argument, calling aforementioned argument and finally the use of return. However, I am not complaining because I imagine this is what much of coding is.


I second this. The requirements on the first exercise are misleading.


hello, can anybody explain what’s wrong with my code in this exercise? Thanks

Write a function called calculateDistance() that calculates the distance between two numbers. The function should return the same result for two arguments no matter what order they’re passed into the function. Your function should return 100 when invoked with -1 and 99 as arguments.

my code, which doesn’t get accepted and won’t pass me through to the next exercise

function calculateDistance($num1,$num2){
echo abs($num1)+ abs($num2);
echo calculateDistance (99,-1);

code provided in the ‘view solution’:

function calculateDistance($first, $second){
return abs($first - $second);