MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

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

PHP palindrome form output confirming 12321 is a palindrome number
12321 is the palindrome number.

Another input is 1234:

PHP palindrome form output showing 1234 is not a palindrome number
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

Encryption using RSA public and Private Key using PHP

PHP's OpenSSL extension can create an RSA key pair, encrypt data with the public key and decrypt it with the private key. This page explains the gist…

Read More

Encryption using Public key and Private key in PHP using mySql database

This tutorial shows how to generate an RSA key pair with PHP's OpenSSL extension, encrypt form input with the public key, store the ciphertext in MySQL, and…

Read More

How to see number of emails sent using smtp in laravel

Laravel does not count or log SMTP emails by default, so a grep will only return a real number once your application writes one log line for…

Read More

What are the Authentication type in phpmyadmin which for config.inc.php

phpMyAdmin supports four authentication types, set per server with $cfg['Servers'][$i]['auth_type'] in config.inc.php: cookie (the default), config, http and signon. This page explains how each one works and…

Read More

What is opcache and Install / Configure in Linux

OPcache is PHP's built-in bytecode cache. It keeps compiled scripts in shared memory so PHP doesn't have to parse and compile the same files on every request….

Read More

PHP Code for Godaddy VPS Server SMTP Email Relay

This page shows how to send email from a GoDaddy VPS through GoDaddy's SMTP relay on port 25 with plain PHP sockets and no extra libraries. Below…

Read More