Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP Numeric String

/*
The PHP is_numeric() function can be used to find whether a variable is 
numeric. The function returns true if the variable is a number or a 
numeric string, false otherwise.
*/

#How to check if the variable is numeric

<?php
$x = 24523;
var_dump(is_numeric($x));

$x = "24523";
var_dump(is_numeric($x));

$x = "124.14" + 100;
var_dump(is_numeric($x));

$x = "Random Text";
var_dump(is_numeric($x));
?>
  
/*This outputs 
bool(true)
bool(true)
bool(true)
bool(false)
*/
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #PHP #Numeric #String
ADD COMMENT
Topic
Name
8+8 =