Verification: a143cc29221c9be0

Php check value is int

Содержание

C++

#include

using namespace std;

bool isNumber(string s)

{

    for (int i = 0; i

        if (isdigit(s[i]) == false)

            return false;

    return true;

}

int main()

{

    string str = "6790";

    if (isNumber(str))

        cout "Integer";

    else

        cout "String";

}

Java

import java.io.*;

public class GFG {

    static boolean isNumber(String s)

    {

        for (int i = 0; i

            if (Character.isDigit(s.charAt(i)) == false)

                return false;

        return true;

    }

    static public void main(String[] args)

    {

        String str = "6790";

        if (isNumber(str))

            System.out.println("Integer");

        else

            System.out.println("String");

    }

}

Python 3

def isNumber(s):

    for i in range(len(s)):

        if s[i].isdigit() != True:

            return False

    return True

if __name__ == "__main__":

    str = "6790"

    if isNumber(str):

        print("Integer")

    else:

        print("String")

C#

using System;

public class GFG {

    static bool isNumber(string s)

    {

        for (int i = 0; i

            if (char.IsDigit(s[i]) == false)

                return false;

        return true;

    }

    static public void Main(String[] args)

    {

        string str = "6790";

        if (isNumber(str))

            Console.WriteLine("Integer");

        else

            Console.WriteLine("String");

    }

}

PHP

function isNumber($s)

{

    for ($i = 0; $i strlen($s); $i++)

        if (is_numeric($s[$i]) == false)

            return false;

    return true;

}

$str = "6790";

if (isNumber($str))

    echo "Integer";

else

    echo "String";

?>