Solved

Is variable a string.

Posted on 2011-03-03
4
234 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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