Checking if a string contains an integer

后端 未结 14 748
北海茫月
北海茫月 2020-12-02 17:10

Do you know of a function that can check if a string contains an integer?

Here\'s how I\'d expect it to work:

holds_int(\"23\") // should return true         


        
14条回答
  •  执念已碎
    2020-12-02 17:39

    comparison.php:

    
    

    Test run:

    $ php comparison.php 
    qwe: false
    23: true
    -23: true
    23.0: false
    -23.0: false
    

提交回复
热议问题