Search
 
SCRIPT & CODE EXAMPLE
 

PHP

check if string is number or not php

$var_num = "1";
$var_str = "Hello World";

var_dump( is_numeric($var_num), is_numeric($var_str) );

/* 
Output -
 bool(true)
 bool(false)
*/
Comment

php check if string or number

 <?php if (is_numeric(887)) { echo "Yes"; } else { echo "No"; } ?>
Comment

php check string is int

<?php
// combination of is_int and type coercion
// FALSE: 0, '0', null, ' 234.6',  234.6
// TRUE: 34185, ' 34185', '234', 2345
$mediaID =  34185;
if( is_int( $mediaID + 0) && ( $mediaID + 0 ) > 0 ){
    echo 'isint'.$mediaID;
}else{
    echo 'isNOTValidIDint';
}
?>
Comment

php check if string or number

 <?php if (is_numeric("cake")) { echo "Yes"; } else { echo "No"; } ?>
Comment

php check if string is integer

<?php
$strings = array('1820.20', '10002', 'wsl!12');
foreach ($strings as $testcase) {
    if (ctype_digit($testcase)) {
        echo "The string $testcase consists of all digits.
";
    } else {
        echo "The string $testcase does not consist of all digits.
";
    }
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php redirect after specific seconds 
Php :: php save image from url to folder 
Php :: how to set session in laravel 
Php :: update query wordpress 
Php :: Turning a StdClass object into an array 
Php :: how to get time php with am/pm 
Php :: file upload in php through ajax 
Php :: get table name of model laravel inside the model 
Php :: laravel whereraw 
Php :: tcpdf error unable to create output file in php 
Php :: redirect to site php 
Php :: scan all directories and files php 
Php :: generating-random-token-php 
Php :: maximum characters laravel validation 
Php :: truncate table laravel eloquent 
Php :: Carbon Format date with timezone in views Laravel 
Php :: php mongodb get all documents 
Php :: artisan cache clear 
Php :: php download rate limit 
Php :: laravel decrement 
Php :: migrate to an existing table in laravel commad 
Php :: php repeat string 
Php :: make controller laravel 8 with resource 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.1/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223 mac 
Php :: laravel blade get authenticated user email 
Php :: how to run a specific migration in laravel 
Php :: how to delete all data from table in php 
Php :: php generate random string 
Php :: create empty 2d array php 
Php :: php get array key by value multidimensional 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =