Obtener el tipo de dato de una variable en PHP

Una función que nos resultará de gran utilidad a la hora de programar en PHP es la función gettype().

Con gettype() podemos conocer el tipo de dato de una variable en PHP. Pero, como te utiliza? Veamos un ejemplo:

$variable="Hola";
echo gettype($variable);
//mostrara: string

Además de la función gettype(), existen otras funciones que se utilizan de forma similar a gettype(), pero sirven para comprobar si una variable es de un tipo determinado. Algunas de estas funciones son:

  • is_array
  • is_float
  • is_int
  • is_bool
  • Etc.

Creo que no hace falta explicar que tipo de dato comprueba cada función!

Autor
Escrito por Jose Aguilar - Director ejecutivo y tecnológico en JA Modules. Experto programador PrestaShop y Experto programador WordPress.
Te ha servido? Valora esta entrada!
(1 voto, promedio: 5 de 5)
Comparte en las redes sociales
¿Buscas trabajo de programador?

8 respuestas a “Obtener el tipo de dato de una variable en PHP”

  1. Jasper dice:

    Its like you learn my thoughts! You appear to grasp a lot approximately this, like you wrote the e book in it or something. I believe that you can do with some percent to drive the message home a bit, however other than that, that is great blog. A fantastic read. I’ll certainly be back.

  2. allofmp3 replacement dice:

    Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.

  3. chaussure de foot dice:

    I was examining some of your posts on this website and I think this website is very instructive! Keep posting .

  4. Aktualne torrenty dice:

    I do not know if it’s just me or if perhaps everyone else encountering issues with your site. It looks like some of the written text within your posts are running off the screen. Can somebody else please comment and let me know if this is happening to them too? This might be a issue with my web browser because I’ve had this happen before. Many thanks

  5. Darmowy Torrent dice:

    First of all I would like to say wonderful blog! I had a quick question which I’d like to ask if you do not mind. I was curious to know how you center yourself and clear your mind prior to writing. I’ve had a hard time clearing my mind in getting my thoughts out there. I truly do take pleasure in writing however it just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any suggestions or hints? Cheers!

  6. Amazing! Its truly remarkable post, I have got much clear idea regarding from this paragraph.

  7. piala eropa dice:

    I believe other website owners should take this web site as an model, very clean and fantastic user pleasant style and design . «It is the sign of a week mind to be unable to bear wealth.» by Seneca.

  8. Hortensia Dieguez dice:

    Loving the info on this internet site, you have done great job on the posts.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.