Jump to content

Search the Community

Showing results for tags 'is_numeric() function'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Write a script that uses a conditional operator to determine whether a variable contains a number and whether the number is even. You need to use the is_numeric() function and the conditional operator. For floating-point numbers, you need to use the round() function to convert the value to the nearest whole number. Save the document as IsEven.php. Reinforcement Exercises1-6 This has been a hard to find solution and I am submitting mine. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22>"]http://www.w3.org/TR...l1-strict.dtd">[/url] <html xmlns="[url="http://www.w3.org/1999/xhtml%22>"]http://www.w3.org/1999/xhtml">[/url] <head> <title>PHPIsEven1-6</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> <form action="isEven.php" method="post"> Input Number:<input type="text" size="36" maxlength="36" name="Fnumber">:<br /> <input type="submit" value="submit" name="submit"><br /> </form><br /> <?php // Carl Skeel # 2012/09/24 $Fnumber = $_POST['Fnumber']; $Number = $Fnumber; if (is_numeric($Number)){ $Result = ""; if( $Number & 1 ){ $Result = "The number (" . round($Number) . ") and is numeric and it's odd!"; }else{ $Result = "The number (" . round($Number) . ") and is numeric and it's even!"; } }else{ $Result = "($Number) is not numeric!"; } echo $Result; ?> </body> </html> I hope this helps anyone on this one! IsEven.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.