Solved

Is variable a string.

Posted on 2011-03-03
4
236 Views
Last Modified: 2012-05-11
Hi,

Very simple, how can I check a variable is a string?

Thanks,
Uni
0
Comment
Question by:Unimatrix_001
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
mars-vie earned 250 total points
ID: 35026073
is_string
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 250 total points
ID: 35026079
if (is_string("23"))
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35026083
<?php
if (is_string("23")) {
    echo "is string\n";
} else {
    echo "is not an string\n";
}
var_dump(is_string('abc'));
var_dump(is_string("23"));
var_dump(is_string(23.5));
var_dump(is_string(true));
?>
0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 35026093
:)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
check mysql insert 12 38
Make login page safer 3 30
PHP Underscores vs. Directory separators 5 26
Group By Function Required in PDF Output 21 30
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question