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 757449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:21:51+00:00 2026-05-14T15:21:51+00:00

Will any one please tell me how to run this class. I am getting

  • 0

Will any one please tell me how to run this class. I am getting the FATAL ERROR: Fatal error: Call to undefined function readnumber() in E:\Program Files\xampp\htdocs\numberToWords\numberToWords.php on line 20 while giving input as 120

<?php 
    class Test
    {
        function readnumber($num, $depth)
        {
            $num = (int)$num;
            $retval ="";

            if ($num < 0) // if it's any other negative, just flip it and call again

                return "negative " + readnumber(-$num, 0);
            if ($num > 99) // 100 and above
            {
                if ($num > 999) // 1000 and higher
                    $retval .= readnumber($num/1000, $depth+3);
                $num %= 1000; // now we just need the last three digits
                if ($num > 99) // as long as the first digit is not zero
                    $retval .= readnumber($num/100, 2)." hundred\n";
                $retval .=readnumber($num%100, 1); // our last two digits                       
            }
            else // from 0 to 99
            {
                $mod = floor($num / 10);
                if ($mod == 0) // ones place
                {
                    if ($num == 1) $retval.="one";
                    else if ($num == 2) $retval.="two";
                    else if ($num == 3) $retval.="three";
                    else if ($num == 4) $retval.="four";
                    else if ($num == 5) $retval.="five";
                    else if ($num == 6) $retval.="six";
                    else if ($num == 7) $retval.="seven";
                    else if ($num == 8) $retval.="eight";
                    else if ($num == 9) $retval.="nine";
                }
                else if ($mod == 1) // if there's a one in the ten's place
                {
                    if ($num == 10) $retval.="ten";
                    else if ($num == 11) $retval.="eleven";
                    else if ($num == 12) $retval.="twelve";
                    else if ($num == 13) $retval.="thirteen";
                    else if ($num == 14) $retval.="fourteen";
                    else if ($num == 15) $retval.="fifteen";
                    else if ($num == 16) $retval.="sixteen";
                    else if ($num == 17) $retval.="seventeen";
                    else if ($num == 18) $retval.="eighteen";
                    else if ($num == 19) $retval.="nineteen";
                }
                else // if there's a different number in the ten's place
                {
                    if ($mod == 2) $retval.="twenty ";
                    else if ($mod == 3) $retval.="thirty ";
                    else if ($mod == 4) $retval.="forty ";
                    else if ($mod == 5) $retval.="fifty ";
                    else if ($mod == 6) $retval.="sixty ";
                    else if ($mod == 7) $retval.="seventy ";
                    else if ($mod == 8) $retval.="eighty ";
                    else if ($mod == 9) $retval.="ninety ";
                    if (($num % 10) != 0)
                    {
                        $retval = rtrim($retval); //get rid of space at end
                        $retval .= "-";
                    }
                    $retval.=readnumber($num % 10, 0);
                }
            }

            if ($num != 0)
            {
                if ($depth == 3)
                    $retval.=" thousand\n";
                else if ($depth == 6)
                    $retval.=" million\n";
                if ($depth == 9)
                    $retval.=" billion\n";
            }
            return $retval;
        }

    }

    $objTest = new Test();

    $objTest->readnumber(120,0);
    ?>
  • 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-05-14T15:21:51+00:00Added an answer on May 14, 2026 at 3:21 pm

    You are using the readnumber function in the class itself, try this instead where it appears $this->readnumber

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

Sidebar

Related Questions

Please tell me if this is correct. In my error handler, I need to
How to pass more than one parameter to a C# thread? Any example will
Estimating how long any given task will take seems to be one of the
I need to compare different data objects. Can any one tell me how can
i am going to call a function which will retrieve some data value from
Could you will please tell me if there is open source C++ projects as
In Perl, is there any way to tell which .pl script has initialized this
Can anyone tell me, is there a way to run a process in IIS
I am trying to write an php twitter script which will be run by
Please Can anyone tell me what happen when i erode an image with a

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.