Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

How to check the given number is either Palindrome number or not in PHP embedded in HTML? -5

How to check the given number is either Palindrome number or not in PHP?

What is the Palindrome number?

A palindrome is a word , number, phrase, verse or sentence that reads the same forward and backward.

Here , we’ll see the palindrome number:

Logic: Its logic has same like reverse number, in further we’ll check the given number and reverse number is equal or not.

  1. First of all, the remainder of $num divided by 10 is stored in the variable $rem. Now, $rem contains the last digit of $num, i.e. 1.
  2. $rem is then added to the variable $rev after multiplying it by 10.
  3. Multiplication by 10 adds a new place in the $rev contains. $rev contain like this 0 * 10 + 1 = 1.
  4. $num is then divided by 10 so that now it only contains first four digits: 1232.
  5. After second iteration, $rem equals 2, $rev equals 1 * 10 + 2 = 12 and $num = 123.
  6. After third iteration, $rem equals 3, $rev equals 12 * 10 + 3 = 123 and $num = 12.
  7. After fourth iteration, $rem equals 2, $rev equals 123 * 10 + 2 = 1232 and $num = 1.
  8. After fifth iteration, $rem equals 1, $rev equals 1232 * 10 + 1 = 12321 and $num = 0.
  9. Now, $num will be existed outside the while loop and $rev contains 12321.

Now , look at this coding

The input number is: 12321

12321 is the palindrome number.

Another input is 1234:

1234 is not palindrome number

Thanks

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

What is CodeIgniter and use cases of CodeIgniter?

What is CodeIgniter? CodeIgniter is an open-source PHP web application framework designed to simplify and accelerate web development. It follows the Model-View-Controller (MVC) architectural pattern and provides…

Read More

What is PHP and use cases of PHP?

What is PHP? Are you wondering what PHP is and how it works? Look no further! In this article, we will explore the ins and outs of…

Read More

Complete guide on PHP certification courses, tutorials & training

What is PHP Hypertext Preprocessor is known as PHP. Many developers use PHP, an open-source server-side programming language, to create websites. In addition, it is a general-purpose…

Read More

Complete PHP with Laravel Certification Guide & tutorials

What is PHP with Laravel? PHP was visioned eventually in the fall of 1994 by Rasmus Lerdorf. PHP means Hypertext Preprocessor. It’s a extensively- used, open source…

Read More

Top 50 PHP Interview Questions and Answers

1) What is PHP? PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. PHP is well suited for web development….

Read More

Complete guide of PHP certification courses, tutorials & training

PHP is a great beginner programming language for anyone who is wanting to cross over into the coding world. Though easy to learn, it is an extremely…

Read More