Even Odd in Php (original) (raw)

Sample Programs in Every Language

A Collection of Code Snippets in as Many Programming Languages as Possible

This project is maintained by TheRenegadeCoder

  1. Home
  2. Programming Projects in Every Language
  3. Even Odd
  4. Even Odd in Php

Published on 16 October 2019 (Updated: 09 May 2022)

Even Odd in Php

Welcome to the Even Odd in Php page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

<?php

if ($argc < 2 || !is_numeric($argv[1])) {
    die("Usage: please input a number\n");
}
 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mi>n</mi><mi>p</mi><mi>u</mi><mi>t</mi><mo>=</mo><mi>a</mi><mi>b</mi><mi>s</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">input = abs(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.854em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">in</span><span class="mord mathnormal">p</span><span class="mord mathnormal">u</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ab</span><span class="mord mathnormal">s</span><span class="mopen">(</span></span></span></span>argv[1]);

if ($input % 2 == 0) {
    echo "Even\n";
} elseif ($input % 2 == 1) {
    echo "Odd\n";
}

Even Odd in Php was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.