Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

is_float(3) [php man page]

IS_FLOAT(3)								 1							       IS_FLOAT(3)

is_float - Finds whether the type of a variable is float

SYNOPSIS
bool is_float (mixed $var) DESCRIPTION
Finds whether the type of the given variable is float. Note To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric(3). PARAMETERS
o $var - The variable being evaluated. RETURN VALUES
Returns TRUE if $var is a float, FALSE otherwise. EXAMPLES
Example #1 is_float(3) example <?php if (is_float(27.25)) { echo "is float "; } else { echo "is not float "; } var_dump(is_float('abc')); var_dump(is_float(23)); var_dump(is_float(23.5)); var_dump(is_float(1e7)); //Scientific Notation var_dump(is_float(true)); ?> The above example will output: is float bool(false) bool(false) bool(true) bool(true) bool(false) SEE ALSO
is_bool(3), is_int(3), is_numeric(3), is_string(3), is_array(3), is_object(3). PHP Documentation Group IS_FLOAT(3)

Check Out this Related Man Page

IS_STRING(3)								 1							      IS_STRING(3)

is_string - Find whether the type of a variable is string

SYNOPSIS
bool is_string (mixed $var) DESCRIPTION
Finds whether the type given variable is string. PARAMETERS
o $var - The variable being evaluated. RETURN VALUES
Returns TRUE if $var is of type string, FALSE otherwise. EXAMPLES
Example #1 is_string(3) example <?php $values = array(false, true, null, 'abc', '23', 23, '23.5', 23.5, '', ' ', '0', 0); foreach ($values as $value) { echo "is_string("; var_export($value); echo ") = "; echo var_dump(is_string($value)); } ?> The above example will output: is_string(false) = bool(false) is_string(true) = bool(false) is_string(NULL) = bool(false) is_string('abc') = bool(true) is_string('23') = bool(true) is_string(23) = bool(false) is_string('23.5') = bool(true) is_string(23.5) = bool(false) is_string('') = bool(true) is_string(' ') = bool(true) is_string('0') = bool(true) is_string(0) = bool(false) SEE ALSO
is_float(3), is_int(3), is_bool(3), is_object(3), is_array(3). PHP Documentation Group IS_STRING(3)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing two float values

I am trying to compare 2 float values using if the foll code does not work a=1.4 b=1.6 if test $a -gt $b then echo "$a is max" else echo "$b is max" fi does -gt work for floating point numbers, if not how do go about for my requirement? can i use bc ? pls help thanks in advance... (2 Replies)
Discussion started by: kavitha
2 Replies

2. UNIX for Dummies Questions & Answers

How to count number of occurrences of a "|" from a variable?

I have a variable, var="some1|some2|some3" I want to know how many "|" are in $var. When I say echo $var | grep -c '|' I am getting only 1 :confused: :confused: :confused: ? (4 Replies)
Discussion started by: jingi1234
4 Replies

3. Shell Programming and Scripting

float comparison

I had a variable 1:80 8 in one varialbe say var=1:80 8 i comapred the below if then -- else ---- thought if condition is true its always going in the else condition....its not giving any compilation errror also....is there any problem bcoz of space... can some one help... (3 Replies)
Discussion started by: mkan
3 Replies

4. UNIX for Dummies Questions & Answers

help assining variables

this is what i'm trying to do... while test -f $newFile echo $newFile already existed, renaming. do variable = 000 newFile = '$newFile.$variable' ((variable += 1)) done echo file name is now $newFile Q - on line five, I'm trying to append the numbers to the end of the file,... (3 Replies)
Discussion started by: Kronk
3 Replies

5. Shell Programming and Scripting

affect variable

hi , i want to store variable but i get always error when i excute this command ligne : var = awk '{print $1}' file1 echo $var how can i store the var? thanks (7 Replies)
Discussion started by: kamel.seg
7 Replies

6. UNIX for Dummies Questions & Answers

Replacing $ in variable

hi I have a variable like k=$DESTDIR/$PKG/$VERSION I want to replace each $ in string k with say "XXX". so that k becomes like this "XXXDESTDIR/XXXPKG/XXXVERSION" when I use echo $k | sed -e "s/\$/XXX" it actually passes expanded of variables $DESTDIR, $PKG and $VERSION to sed. ... (10 Replies)
Discussion started by: ashish_uiit
10 Replies

7. UNIX for Dummies Questions & Answers

Searching for a string variable

Hi ... I have a string variable STR = "This is a test message" I have a file abc.txt that I am searching for the occurence of the string STR ... I am using the command in a script cat abc.txt | grep $STR It identifies each space as a seperator and prints word by word. How to... (2 Replies)
Discussion started by: mattrix
2 Replies

8. UNIX for Dummies Questions & Answers

variable

do not know why this piece of code does not work echo "enter input" read input if ; then echo the input is abc else echo the input is wrong fi thanks for the help (2 Replies)
Discussion started by: christine33990
2 Replies

9. Shell Programming and Scripting

Perl data type checking

I am using perl 5.8.0. I need to check some values to see it they are floats. Our system does not have Data::Types so I can't use is_float. Is there something else that I can use? The only thing in Data is Dump.pm. I am not allowed to download anything to our system so I have to use what I have.... (3 Replies)
Discussion started by: ajgwin
3 Replies

10. UNIX for Advanced & Expert Users

Usage of $ as variable name

Hi I have to use a Environment variable and that variable has $ prefixed to its name like, $var=/home/source/test/ i need to use the variable as i have show above. :confused: Help requested..... Thanks in advance... (6 Replies)
Discussion started by: shreekrishnagd
6 Replies

11. Shell Programming and Scripting

ksh : find value type

Hi, Simple question : How to find the value type from a variable : Ex : var="1" => type is numeric var="a" => type is character Thx :D (3 Replies)
Discussion started by: madmat
3 Replies

12. Shell Programming and Scripting

awk with variable

echo "abc: cdef" | awk -v var=abc -F: '/$var/{print $2}' I want to match the line contains abc but the "abc" need a variable "var" to instead, this doesn't work. any help? Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies

13. Shell Programming and Scripting

If echo statement return false

I have this code that sometimes return a false value and the code inside the if statement gets executed and error out. Any idea why? thanks. So I set a debug and see what the value for $ScriptElapsedTime Here is the value I got ScriptElapsedTime='03:20'. Base on this value the if... (10 Replies)
Discussion started by: nugent
10 Replies

14. UNIX for Dummies Questions & Answers

Output checker setting variable to TRUE or FALSE

Hi All, I'm trying to come up a way to check the output of some data i have. I need to be able to check for the order of the output and if its correct set a variable to false if it isnt. Currently the data is in the below format, this is the value which should cause the variable be set... (4 Replies)
Discussion started by: mutley2202
4 Replies

15. Shell Programming and Scripting

Replace substring from a string variable

Hi, Wish to remove "DR-" from the string variable (var). var="DR-SERVER1" var=`echo $var | sed -e 's/DR-//g'` echo "$var" Expected Output: However, I get the below error: Can you please suggest. (4 Replies)
Discussion started by: mohtashims
4 Replies