Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:26:38+00:00 2026-06-09T22:26:38+00:00

I have used this code which shows an error:ie if my meters is 175m

  • 0

I have used this code which shows an error:ie if my meters is 175m but when i convert it does’nt show that thing

<?php
function metersToFeetInches($meters, $echo = true)
{
    $m = $meters;
    $valInFeet = $m*3.2808399;
    $valFeet = (int)$valInFeet;
    $valInches = round(($valInFeet-$valFeet)*12);
    $data = $valFeet."&prime;".$valInches."&Prime;";
    if($echo == true)
    {
            echo $data;
    } else {
            return $data;
    }
}
?>
<?php
$feetInches = metersToFeetInches(1.75,false);
echo $feetInches;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:26:39+00:00Added an answer on June 9, 2026 at 10:26 pm

    This is one of those things you can easily find on Google, but I guess you didn’t look further than the first link.

    Anyways, you should do it like this.

    <?php
    
    function metersToFeet($meters) {
        return floatval($meters) * 3.2808399;
    }
    
    ?>
    

    But why is this better than the code you posted? Well, functions are not supposed to do everything. You should write a function for a certain action, not one big function with everything you can every need. Because if you need to add something to that function or change the order of actions, it’s a hell of a lot of work.

    Furthermore, your function has an option $echo. But why would you need that? You can add such an option to every function, but PHP has a nice commando for that: echo. So instead, it’s way better to write echo metersToFeet(10). Or $value = metersToFeet(10) if you need to save the result in a variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
I have used this code for extracting urls from web page.But in the line
I have some rrdcgi scripts with HTML code which are used to show graphs
I have an error in my program which says that 'count' cannot be used
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,
I have used this code to store Object to a file: try{ FileOutputStream saveFile=new
I am creating a rails app and have used this code in one of
the xml <publication_date media_type=print> <month>1</month> <year>2011</year> </publication_date> I have used this code to get
I have used this custom grid view in my code, and I want to
I've used this code to have a like btn on my site: <iframe src=http://www.facebook.com/plugins/like.php?href=URL_OF_YOUR_WEBSITE&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80&amp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.